Your muscles need oxygen to produce energy in a process called cellular respiration. The energy is used to fuel muscle contractions. Exercise increases your muscles' need for energy and thus more oxygen is delivered to your muscles. Once oxygen is delivered to your muscles, it doesn't leave your muscle cells but is converted to other molecules.
Your body obtains oxygen from the air you breathe. Oxygen is transferred through the alveolar epithelial surfaces of your lungs to your blood and then carried to your muscles. Your muscles use the oxygen molecules during cellular respiration to transfer energy from glucose and fatty acid molecules to a molecule called adenosine triphosphate -- ATP. ATP is then used to provide energy for muscle contraction.
During cellular respiration, when oxygen is consumed and ATP is produced, another gas molecule called carbon dioxide -- CO2 -- is produced. CO2 is a waste product and is removed from your muscles to blood and carried to your lungs. CO2 is removed from your blood and finally expelled from your body when you exhale.
Exercise increases the work load of your muscles. This increases the energy need and ATP production rate in your muscle cells. Your breathing rate will increase when you exercise to ensure that enough oxygen is delivered to your muscles to keep up constant ATP production. Oxygen does not leave your muscles during exercise but it is used in cellular respiration to produce ATP and CO2. CO2 is the gas molecule that is removed from your muscles during exercise.
Aerobic vs. Anaerobic
Exercise increases your muscles' oxygen demand and thus, oxygen delivery to your muscle cells is enhanced during physical activity. During aerobic exercise, oxygen delivery to your muscles is adequate to produce ATP molecules. However, if you increase your exercise intensity to a point, during which your circulatory and respiratory system cannot deliver oxygen fast enough to keep up ATP production, you enter an anaerobic exercise. ATP production is interrupted during anaerobic exercise and your muscles are producing energy by converting glucose to lactic acid. You can only keep up anaerobic exercise for short periods before your muscles run out of energy and begin to fatigue.