Headshot is an ability for the Sniper to achieve by hitting an enemy player in the head,
for Spies hitting in the head with the Ambassador. Spies shooting with the Ambassador has to wait until the cooldown timer has reset to guaratnee a headshot kill, otherwise shows an Ambassador gun kill icon in the death board.
Hitting a headshot takes practice. Enemies tend to move around a lot, making it harder to get a headshot.
You'll have to hit the area where you predict the enemy is going. For Snipers, it takes approximately twenty-three milliseconds after scoped in order to prevent a Sniper scoping and getting a headshot kill immediately. For Spies with the Ambassador, it takes approximately 0.95 seconds for it to cool down to register the kill as a headshot.