I have a pain in my head behind my right ear it is like an electrical shock that comes from time to another what is it?

Nerve. A very quick electrical shock like pay is typical of a nerve pain, neuralgia. Sometimes a serious problem is the reason for neuralgia, but that is fairly rare. An old remedy is to make sure you keep your head warm, wear a cap and never go outside in the winter with your hair wet.