It seems the cause of this problem is the little info box that is shown to let you see teammate HP and other info. If this is the case, then there should also be lag when looking at enemies as Spy (Or with the Solemn Vow as Medic). I have not seen this problem before, so I'm going off of info that has fixed all other odd/laggy problems that I have had many of.

If you haven't already done this, try doing the following:

Verify the integrity of the game files (Right click on the game in your library, go to "Properties", go to the "Local Files" tab, and click "Verify integrity of game files)

Delete all content within your TF2 custom folder (Located in "Steam\SteamApps\common\Team Fortress 2\tf\custom". You can probably keep the 'readme.txt. file)

I reccomend verifying the integrity of game files after deleting custom content, but it shouldn't be necessary to do it twice.