This can happen underwater as well as above and can give you a feeling of running out of air or being short of breath. You should first STOP, BREATHE, THINK, and ACT.
Notify your buddy to stop, and cease all activity. Then, take a series of slow, deep breaths to try and regain normal breathing patterns. When you have recovered, continue the dive but control your activity level.