What causes random backaches?

Dear Doctor, I am 26 years old and for as long as I can remember, I have suffered with random backaches. Sometimes, I do not get one in like two months, but then it comes back. I visited a doctor but he only prescribed pain killers. When I get my period, it gets worse. I feel like someone is stabbing me with a knife. What is the reason behind this? It normally lasts a few minutes, maybe 20 at the most, but I’ve failed to follow how often. It feels like all the time. Do I need a scan? Is there a deeper problem?
no image
Dr. Rachna Pande