When you're shocked, or surprised, in a good or bad way, so you suddenly breathe in a gulp of air—! That's a gasp. To gasp is to pull air into your mouth suddenly, because you're surprised by something. And, a gasp is the air that you suck in, or the sound of it. When you gasp, you might open your mouth wide, and, to be polite, you might cover your mouth with one or both hands.
(Source) Maybe you've just gotten a papercut. (Gasp!) Maybe you've spilled your entire drink. (Gasp!) Maybe your very favorite song that you haven't heard in a year has just started to play. (Gasp!) Maybe you've just bumped into your teacher outside of school. (Gasp!) Maybe someone has just handed you a wonderful surprise gift. (Gasp!)
Usually, you gasp when you're surprised. But you might also gasp if you're exercising hard, and you're trying to get more air into your body. If you just ran a mile, or just did a hundred jumping jacks, you could be gasping for breath.