It depends on which device you have a pacemaker or defibrillator. If it is a pacemaker only, a magnet turns off the sensing of the device (that is what makes the pacemaker see your own heart beat). While it won't hurt you, it can make you feel uncomfortable and is not recommended unless checking it on the telephone.
If it is a defibrillator (which all defibs have pacesmakers built into them), is a whole different subject. In this case a magnet will suspend the shocking part of the device, but not the pacemaker part. This can be very dangerous because if you have an arrhythmia
it needs to treat, as long as the magnet is there, it won't be able to treat it and that can have dire consequences.
In a nutshell, don't place a magnet near any device that is keeping your heart beating.