The short answer to this question is, as long as you (and your baby) want to. The problem of course with this answer is that what we want is so deeply influenced by societal norms and the opinions of others, and additionally what the media and commercial markets have to say about it.
It means that when you ask the question, how long should I breastfeed for? You are really asking lots of different questions including, when will people think it is too weird to continue? What is normal? What is best for my baby? Will I damage my child by continuing to breastfeed? What will people think of me as a parent if I stop/continue breastfeeding? What is the value of breastfeeding beyond infancy?
So let’s change the question and look at the facts first.
What does breastfeeding look like in evolutionary/biological terms?
When we watch nature programs we never stop to think, why is that fox/elephant/giraffe BREASTfeeding? Why? Because we expect mammals to feed their young with their own milk. We also expect that whenever they stop feeding is the right the time for them to stop, because they are merely following their instincts and doing what they need to do. Human Beings have long since stopped following our instincts in many respects. We can sometimes even think that our ability to make reasoned and conscious decisions actually makes us superior to other animals. Maybe it does, when it comes to investing in the stock market, or when we engineer earthquake proof buildings, but listening to our instincts is not an inferior way of making decisions, it is how we have survived and evolved over millennia into the complex beings that we are today.
What is normal? Well, it is normal, biologically, to breastfeed our young until they naturally self-wean. This tends to lie anywhere between aged 3 and aged 7 (but can fall either side). If you think of the term ‘milk teeth’ and consider that it is no accident that our first set of teeth are lost and replaced between these ages, it makes sense then that our smaller teeth in a smaller mouth and jaw, which make latching and suckling possible, would make way for larger adult teeth at a time that coincides with the need for nursing to be reduced or stopped.