My boy scratches his ears and eyes when he is sleepy.
He used to scratch his head when he had cradle cap which made the scalp itchy. After the cradle cap subsided he still scratched for fun.
Now he doesn't scratch anymore.
I think your boy scratches his head now because he is curious? I think he's at the age where he is discovering that he has a head and hands he can use. Once he finds something more interesting, he will stop scratching his head. That's of course if you've confirmed that there's nothing else wrong with his scalp or ears.
Sometimes a build up of wax in the ears could cause them to scratch because it is itchy. My boy scratches his ears often due to ear wax. My doc gave me some ear drops to drop into his ear every month to clear the wax.