A pacemaker is a small device that sends electrical impulses to the heart muscle to maintain a suitable heart rate and rhythm. A pacemaker may also be used to treat fainting spells (syncope), congestive heart failure, and, rarely, hypertrophic cardiomyopathy. It is implanted just under the skin of the chest during minor surgery. The healthy heart has its own pacemaker that regulates the rate at which the heart beats. The heart has its own pacemaker that regulates the rate at which it beats. But some hearts don't beat regularly, a problem called arrhythmia. Often, a pacemaker device can correct it.