If you notice that your heart races when you exert yourself, by doing exercise or getting anxious and stressed, then that is normal. The heart is working hard to pump the blood carrying oxygen around your body.
If your heart starts to race for no reason at all while you are resting and calm, then I would suggest you see your doctor to get your heart checked out for any abnormalities.
I agree and want to add that if your heart races with no activity you could have an arrhythmia (benign or not) and should get a EKG and if they see nothing on that (EKG's don't pick up all arrhythmias) a 24 hour monitor that you wear at home and a echocardiogram would be good to cover both electrical and structural problems. I have a benign arrhythmia and I had these tests done to find out which one. I just quit drinking caffeine and cut way back on sugar. But some arrhythmia's require meds.
My daughter-in-law has Supraventricular Tachycardia (SVT). This is a heart condition causing episodes of an abnormally fast heart rate. It was only found last year and she was told that she has had this since birth - she is 29 and pregnant, but only started to get extremely fast heart rhythms whilst at rest last year when she was a few months pregnant. This is a 5th pregnancy, she had no problems with the previous pregnancies.
Her heart rate has gone as high as 224 beats per minute. She is on medication which is working. A normal heartbeat should be 60-100 beats per minute at rest.
In SVT the heart rate may be as high as 250 beats per minute, but is usually between 140 and 180.
A racing heart is due to the atrial node pacemaker inappropriately regulating the rate bwith which the heart beats. There are many possible reasons for this, magnesium deficiency being the most common. Sometimes this is a side effect of a medication or even a cup of coffee. Usually such a patient will have a normal EKG unless having an episode. If there are several such episodes you really require an evaluation by a cardiologist. This not necessarily life-threatening, which is your primary consideration, however if this is chronic, it requires professional evaluation and treatment. Generally treatment may be as simple as diet (MSG can cause this problem, sold in stores as "Accent"). Do not use magnesium supplements except under a physician's supervision. The second level of treatment involves drugs, of which there are a number with an established record of safety. In a certain universe of cases a surgical procedure called ablation may be recommended. It can also be caused by anemia or dehydration. It is not a rush to get it checked out, but you should do so in a reasonable period, because if the heart vrate increases too much there is an increases probability of a condition called ventricular fibrilation.