'Panting' is a rapid succession of shallow breaths. Dogs pant when they're excited. If a person has been running fast, they might pant. Mothers-to-be in labour are sometimes told to pant.
'Gasping', by contrast, is when you take one or several sudden deep breaths. You might gasp when you hear shocking news. If you are under water for a long time, you come up gasping for air.
In the context you describe, either verb could be appropriate, but 'gasp' is the correct verb in this particular sentence. This is because 'gasp for breath/air' is a set phrase.