Alrighty, I'm just an open scrub, so don't take my unimportant opinion too seriously, but anyway...
I guess the most unsatisfying answer is that it always depends on the situation..
Let's imagine your team is winning the midfight with noone of your team dying and the enemy team going down 3 damage classes and you're chasing the medic and his heal target. In this situation you basically already won the fight with a few enemies surviving so I think nullifying their ubercharge with a demo or scout surviving and you going down will benefit your team much more than the other way around since your team can now push with a full uber advantafge on last.
On the other way around if the midfight or another battle starts and there are no clear advantages or disadvantages in numbers it's still pretty much dependent on the current uber situation. If you're on an uber disadvantage you may try to get their medic while saccing yourself to change that, if not you should probably get their damage class or retreat so your medic and team has time to build to nullify the disadvantage.
Despite all of this you should always know that taking a 1v2 is always kinda risky and if you're playing against equal players it's not always really worth it so for actual success you should - if possible - have people fighting with you or following up to maximize your team's success.
Another thing you should consider is that if you're killing the heal target you probably won't have that much problems killing the healer as well. On the other hand you shouldn't underestimate the power of an overhealed player against an nonoverhealed player...
What I actually think matters the most is playing with your team and listening to the calls while still keep the ubercharge for both team in your mind. Let's say your demo says "medic took a pipe" always go for the med, since he has only 50 hp left and there's a pretty big chance killing him, If your team says demo down, scout took 50, soldier took a lot or whatever, always go for the damage classes since these are weak and by fragging them you assure your teams benefit. Also you should really listen to your "team plan" aka what your main caller sais. Whatever the aim of your attack (or hold) is depends on the enemy medic having advantage/disadvantage or what you try to achieve. I guess it's kinda impossible to answer your question since comp tf2 isn't just dm but much more a team working together.
Once again, I'm a bad player who's stuck in open with basically no legit knowledge, so if you disagree with me (which is likely since people here do most likely know how to play) not just downfrag, please correct my mistakes so that not just OP will learn, I'm 'stupid' after all as well. Thanks!