Hi,
This is where it comes from.
If you are 1.5 metres tall and can't swim, and the water is 2 metres deep, you are in trouble because 'you are in over your head'. Another version is to say 'you are out of your depth'.
It's a general way of saying you are in difficulties.
Best wishes, Clive