When is it a good idea to punch people?
As a Heavy, I have in my posession what is arguably the most powerful close-range weapon in the game. One that can shred through an enemy in fractions of a second.
I am also in posession of the biggest 'guns' in the game, them being my massive fists of doom.
Which seems redundant, given the large number of boolits I can shoot with my mighty mighty gun.
So when is it a better idea to spend the time switching to my fists for a good punchfest, over holding out my minigun and preparing for a mowdown?
As with almost every melee weapon, the answer is almost never. This is especially true with the heavy- you have the strongest short range weapon in the game as your primary weapon and you are far too slow to easily punch anyone.
Even if you are out of ammo, punching someone is still a bad idea. A non-critical melee attack usually* deals 65 damage and takes almost a second between attacks. This gives your target plenty of time to back away and shoot you. At this point there is nothing you can do to your target- they're faster than you.
If you're looking for a weapon that doesn't need spinning up, use one of the Heavy's shotguns.
The real use for your fists is you can swap them for either the Gloves of Running Urgently, which cause you to run faster and take minicrits when wielded or the Fists of Steel, which reduce incoming ranged damage and increase incoming melee damage when wielded.
*Scout, spy and certain unlockable melee weapons change this.
In most situations, Heavies have the most problems in melee combat because they're the slowest of everyone (even though they can take 5 melee hits). There are however times when yes it is a good idea to punch someone.
- If you don't have the ammo or the time to use your minigun and you've decided to not be carrying a shotgun. Should you have chosen to use the Sandvich or something, your fists are your best option if something jumps you.
- If you're feeling lucky or daring. The worst crit chance for melee weapons (15%) is greater than the best crit chance for guns (12%), and one crit punch will kill anything weaker than a full-health Soldier in one hit (and give you an achivement for doing so). This of course depends on the server - random crits have to be on, and you might want to be facing opponents who want to outmelee you rather than just shoot you.
- If your Medic asks nicely. There's a Medic achievement for übering a Heavy and having him punch (not necessarily kill) two different enemies.
- If you have the KGB equipped. Trying to land the final hit on an enemy with them will give you five seconds of crits, which you can chain together in a punching blaze that can get a respectable amount of kills on an unprepared team.
- If you have the Holiday Punch equipped. While its crits won't autokill most enemies, getting trapped by the laughing and likely subsequent tauntkill will probably humiliate and anger most opponents, which in most cases causes them to play worse.
First off
The mini-gun is the heavy's best weapon
So know that I agree with the previous answer which states that if you are trying your best to help your team, get kills and rack up points you don't ever really want to go with fists over firearms.
With that said I do think this question deserves a list of situations where the heavy's melee arsenal could work even if they are a bit silly.
Fists of Steel versus charging slow enemies. If enemies are running directly at you (say you are defending a control point) then fists of steel can be effective. Most notably this is the case against slow soldiers and sometimes heavies. Use cover if you can then get up in their face and destroy it! Soldiers and demos will be getting hurt more from their own splash damage than you do and your pool of HP can get you through.
Retreating. If you need to flee a meat grinder of an area or a deadly opponent then the gloves of running urgently are your best bet. Fists can at times be preferable to the mini gun in granting you the ability to attack someone while you still ran away (though obviously the shotgun would be better for this).
General purpose in narrow corridors or when your enemy is pinned against a wall then your enemy will have a hard time running away from your fists.
This list could probably be improved and expanded upon.