You could have a heart rhythm abnormality called paroxysmal atrial fibrillation. This is actually quite common and not dangerous when there are no symptoms other than palpitations. The other possibility is frequent premature beats. Repetitive premature electrical activity in the upper chambers (premature atrial beats) or lower chambers (premature ventricular beats) of the heart would cause palpitations that would feel similar to atrial fibrillation.
If you otherwise feel well and just have palpitations when it occurs, stop what you are doing, sit or lie down, and take some slow deep breaths. If the palpitations do recur, call your doctor's office for advice.
Your doctor may want you to have some additional testing.
Please provide feedback to help us improve the Drugs.com Symptom Checker.