Generally speaking, sunglasses shouldn't give you headache.Your headache maybe caused by the poor quality of your lenses or the unadjusted frames or there is some prescription on your lenses.You may go back to the store to check if there is something wrong on your lenses or adjust your frame to the right position which fits you well.
Make sure whether your sunglasses have prescription. If they do have, then your headache may due to the wrong prescription.Then you should take your sunglasses to your eye doctor to have a check and let them remake for you. If your sunglasses have right prescription, then your headache may be caused by the coatings on the lenses. If your sunglasses cannot block 100% UV rays, then you will get headache when you are exposed to the bright sunshine.