It could be one of several things. A
panic attack, an excess of caffeine, or even a sudden intake of a lot of carbs/sugar if your blood sugar is low.
I suffered through several panic attacks, wherein the heart started pounding and I felt like I was going to die. The first time I thought I was having a
heart attack, because that feeling of impending doom is one of the many symptoms of heart attack. Anyway, my doctor sent me to a cardiac specialist, and they took an
ultra sound and fitted me with a heart recording device for 24 hours. Everything came back negative for cardiac problems [my arteries were nice and clear]. The specialist said I had a non-life-threatening condition called PVC ["Premature Ventricular Contraction"], which is a form of an irregular heartbeat -- the heart throws in an extra beat, and gets out of whack, and when you sense it you start panicking and the body releases some adrenalin -- a nice little vicious cycle.
So, my doctor prescribed
Xanax, and I was on that for a couple of years -- several cardiac rhythm irregularities ended up making me paranoid of going to bed [that's when my attacks happened]. I've since weaned myself off them, but I still have a small supply for those occasions that a panic attack tries to start [about every two months].
By the way, we figured out that the initial cause was partially my caffeine intake. For over 20 years, I would regularly drink upwards of 15 cans of Diet Coke daily. When the cardiac specialist heard that, he surmised that my body was finally rebelling against it. He advised me to stop drinking anything with caffeine, and I went
cold turkey. That was about five years ago, and I don't miss it one bit. :-)
I'm in better shape than I was back then, but I still have to consciously force myself not to be paranoid about my heart beat. Trust me, it's hard at times. Ho hum.