With handguns, usually it’s the magazine’s buttplate. It’s not technically the heaviest part of a gun, but if loaded, it’s close. It’s also devoid of operator controls (in most cases), and is unlikely to be damaged if you clock someone with it.
It can be used either while the pistol is in a normal firing grip, by bringing it down onto the target, or while holding the barrel as an improvised grip, and using the actual grip as a strike surface. (Incidentally, I’ve known a few Marines that used to joke about simply using Mk 23s as improvised hammers.) Both approaches also work with most revolvers.
It’s also probably worth remembering, this is one of those things that is basically never useful. (Unless you intend to use your pistol for hammering tent stakes. In which case, don’t, it’s a really terrible idea.) If you have a gun out, and you’re in a situation where you should be shooting someone, you probably shouldn’t simply hit them with the gun. It won’t knock them out, but it will make them angry. At which point, better to have them angry and leaking blood everywhere than angry and trying to beat you to death with your own gun.