I'm a US speaker. I've never heard "to scratch your _brain_." "To scratch your _head_" is an idiom for "to think hard and long." When you are thinking about something, it is not unusual to fiddle around without your hands, and one of the common things people do is to scratch their heads. That is, _literally_ scratch their heads.
To "scratch your brain" sounds like someone making a joke by slightly changing the standard phrase."
I agree with others: I "rack my brain" and I "scratch my head" but I don't "rack my head" or "scratch my brain."