Oh, you bought a pair of prescription sunglasses. It may cost you more money than a pair of plano sunglasses made by the exactly same materials. So I think you should turn to the optician and ask him or her to find out the possible reasons and help solve the problems. I think he or she has the responsibility to do this for you. Good luck!
Wearing sunglasses cause headaches have several reasons. For example, it may because you choosing wrong colored sunglasses lenses. It may also caused by the poor quality of the sunglasses. Or the power of the sunglasses lenses not fit for your eyes. Or the design of the sunglasses make the sunglasses lenses too close to your eyes and cause headache.
Well, maybe the power of the lenses doesn't fit for your eyes. I suggest you to have your eyesight checked in the morning other than in the afternoon, because the result of the exam will be more accurate. Your eyes will feel tired in the afternoon. If you have your eyes checked at that moment, the degrees of your eyeglasses will be stronger. And this may cause headaches.
The prescription sunglasses are just like the prescription glasses. They have degrees on their lenses, so you may need to spend some time to adapt to them. Usually it will take a week for a person to adapt to a pair of new prescription glasses or sunglasses. But this may depend because some people may spend less time on it. While if the symptoms persist in future, you may need to have your eyesight checked by an eye doctor or have your sunglasses checked by an optician. Maybe there is something wrong with the power of the sunglasses.
Maybe your sunglasses are of poor quality so that they can't protect your eyes from the UV rays. We know that if we stay in the outside for a long time without any protection in summer, we may feel dizziness and headaches. If you sunglasses can't protect your eyes, you will suffer from dizziness and headaches too. You should buy the sunglasses with UV protections the next time. Good luck!