Yawning is an involuntary reflex by the body to control the levels of carbon dioxide and oxygen in the blood. The yawn draws more oxygen into the lungs through a deep breath.
Typrically this happens after periods when the oxygen level is low as we have been taking short shallow breaths. This tends to happen when we are bored or fatigued. If we do it when exercise its probable due to the fatigue or just the fact we have been breathing in a restricted way well exercising