BattleTech explores this to a degree. While obviously mechs in the game have heads in order to look cool (and because headshots are a game mechanic), they do have in-world reasons for them as well.
Basically, since internal space and heat are major issues for BT mechs, providing a comfortably roomy environment at a human-survivable temperature is much easier in a part that juts out of the body than crammed in right next to the reactor. As a result, torso-mounted cockpits tend to be cramped and subject to heat issues. To make matters worse, nobody could get ejector seats to work with them so they’re less survivable in case the mech gets blown to pieces.
All of which is really unfortunate as everyone in the setting is aware that any major hit to the least-armored part of the unit is likely to result in a mission kill. The trade-offs of torso-mounted cockpits make them uncommon, however.
(Note: Visually, there are mechs with no apparent head in BT. Mechanically, a head is always present even if the cockpit is in the torso. That head might just be a section of the torso with a window in it but mechanically it’s there.)

