This could be a medical or dental problem. The possibilities are way too many to try to give you any meaningful or accurate advice over the internet.
Have you been seeing a dentist for routine checkups? Where did the pain seem to originate and for how long have you had it? Perhaps start with your primary care physician who may feel it appropriate to refer you to a dentist for an evaluation.