The heart reacts that way for short periods (few seconds) when interacting with caffeine,nicotine
and other stimulant
drugs or medication.This is normal.
However if you are at rest and drug free and have persistent heart rhythm variation for long periods of time...say from 20 minutes to several hours you must see your doctor. Heart arrhythmia
when untreated can lead to more serious condition.