Depends on the weapon, the range, the opposing hero...

Is the weapon pinpoint accuracte or does it have a spread. Does it shoot one bullet or even more than one pellet per shot. Can it deal critical damage or not?

For example Widows weapon has a higher headshotmultiplier that will very likely kill the target. Headshots are crucial since the target will be in cover as you can hit the second bodyshot.

Ana cannot headshot at all so Shooting at the legs is better since the hitbox is broader.

Reapers shotgun has a wide spread so unless you are right in the face of someone it is better to shoot the Body since it will hit more pellets.

Torbjörns shotgun has a pretty tight spread. Shooting necks at medium range is very viable.

Soldiers first 3 shots are pinpoint accurate. You can tap the button on heads at Long ranges or hold the button at necks at medium ranges.

Shooting at Roadhog or D.Vas crititcal hitbox is pretty much the same as aiming for the Body, since if you miss it you will still hit the Body.

Most important is to kill someone. On a regular Basis that means that you want the burstier damage of headshots since supports have tougher times to bring the target up. But if you can Keep them so incredibly buisy healing the backline that the tanks don´t get any healing anymore it can be worth to go for the sustained lower damage.