How much of this wood molding has to be completely replaced?
Depends on what your goal is: saving money, saving time, easy repair for you to do, good enough vs. historically accurate, etc.


The trim is quite square, so replacing it will be low labor, and therefore cheaper if you have someone else do it (interior/trim carpenter). Pry it off carefully, measure new boards, cut, a few pins and a little glue, and you're ready for finishing. In the bottom picture, the trim is starting to show a gap in the mitre anyway (at the opposite end from the damage)--so if you want it to look perfect, it's worth it to pull it all off. You could also go with a different trim look if you wanted.
You could probably get away with filling all of that with wood putty or (preferably) epoxy and smoothing it out. There are a ton of guides about how to do this available on YouTube/etc.; here's one on This Old House. This is more highly-skilled work (IMHO) than simply pulling the board out and cutting a new one to match, but it is less invasive.
Another option is to round or champfer the trim in that area. This is clearly a place where wear occurs, so why make it perfect just to have it banged up again? Take a plane and match the angle of the damage. You'll still have to fill the damage on the face of the trim. Obviously this will change the aesthetic, but sometimes there is a design element from nearby woodwork that you can emulate.


(You do any of these yourself, but unless you've got skill and experience it's likely to look...like you did it yourself. Which may be fine, but if you want a perfect home, this isn't a great place to start learning as it looks like it's a public, visible spot.)

Whichever way you go, the hard step will be matching that patina. It could be quite tricky and eat up much more budget than the actual carpentry--depending on how perfect you want it. If you're planning on repainting the trim anyway, of course, this is already part of the project--but don't underestimate the effort to match what looks like an old stain.