What you are supposed to do first is see a doctor. Just because something is in your head doesn’t mean that there might not be a real problem. It’s always important to check on the medical facts first. If there is a medical root to your problem, the first step toward a cure is to get a diagnosis – which will lead to a discussion about treatment. But without a diagnosis, you are only making yourself crazy thinking about all the possibilities.
If you are medically clear, then we’re looking at a psychiatric issue. You are probably correct that this is anxiety-based. Where you are not correct is in thinking that an anxiety pill is going to fix what ails you. The medicine will help settle you down, it’s true. But you also need to learn how to calm yourself and interrupt those racing thoughts that lead to a full-blown panic attack. Cognitive-Behavioral Therapy has been found to be very effective with people like yourself. Take a look at “Feeling Good: The New Mood Therapy” by David Burns. The book is very readable and easy to understand. You may find that you are able to use the tools described in it on your own. If not, please consider finding a therapist to coach you. There is no reason to go through life going “out of your mind.”
I wish you well.