We definitely don't say this in America. We would say "What was I thinking!"
Just imagine this as the next scene in the morgue (after 'this is your arm and this is mine). Like two corpses that by some reason lost their body parts and now are trying to find them...
"голова" is used here in the meaning "thinking, reasoning", but not a body part. As a native Ukrainian speaker I think that "Where was my head?" is not actually correct translation
To stop the confusion:
Yes, this is an idiom that means "What was I thinking?!"
But also yes, it can literally mean "Where was my head?" xD
(for the ones with a good imagination)