Gabe Mirkin, M.D.
When you exercise, sugar is broken down into different chemicals, to produce energy for muscles. As long as you get all the oxygen you need, the final products are carbon dioxide and water, but if you exercise so vigorously that you can't get the oxygen that you need, the reactions stop, causing a chemical called lactic acid to accumulate in your muscles and spill into you bloodstream.
Lactic acid causes muscles to hurt and makes you feel tired. You breathe hard and fast and slow down to catch up with your oxygen debt, which converts lactic acid into carbon dioxide and water that are blown off as you breathe. Blood levels of lactic acid lower and your muscles stop hurting. A pace that you can hold breathing deeper and faster, but not gasping for breath is called the lactic acid threshhold and is the training level for most competitive athletes.