Your heart rate is actually tied in to your breathing rate in a phenomenon called "respiratory sinus arrythmia (RSA)". When you normally breathe in (inhalation), your heart rate increases slightly and then decreases again when you breathe out (exhalation). Scientists aren't really sure as to why your heart rate is linked with your breathing, but some studies suggest that the human body saves energy in this way, by increasing the efficiency of oxygen and carbon dioxide exchange in your lungs.
Link between respiration and heart rate
Energy efficiency may be increased by lowering your heart rate during an exhalation, as unnecessary heart beats are inhibited during periods of lower oxygenated blood. If we know RSA to be true, then why does your heart rate decrease during a deep breath? The deep breath in this case is what is referred to as the "valsalva maneuver" — taking a big breath in and then attempting to forcibly exhale with your nose and mouth closed (think of trying to lift or push a really heavy object).
During the early phase of the valsalva maneuver, the pressure inside your rib cage is so great that it compresses blood vessels, like the aorta, as well as the walls of the heart, decreasing the amount of blood flow to the heart and decreasing the cardiac output (how much blood is pumped by the heart). This can be seen by a rise in aortic blood pressure and decrease in heart rate (Phase I). Heart rate and aortic blood pressure are very closely linked, so as soon as the heart rate falls, blood pressure decreases. This causes heart rate to increase again (phase II). Once you start breathing normally and the pressure is released, your heart rate and blood pressure eventually return back to normal.
This answer was written by Csilla Egri, a Master's student in Biomedical Physiology and Kinesiology at Simon Fraser University in British Columbia.