The sensation of difficulty breathing can definitely be one symptom of an anxiety
reaction, such as a panic attack. However, it is important for you to schedule an appointment to speak with your doctor
about this occurrence so that he or she can obtain a more thorough history, perform a physical examination, and run any testing that may be indicated.
Having said that, the sensation of shortness of breath can be due to a large number of conditions, that can originate in a number of organ systems, most commonly the heart or the lungs. On the other hand, if you are young and without other medical conditions, it is unlikely that you are having symptoms from a chronic heart or lung disease. Also, the timing of your symptoms are not consistent with these types of conditions, as it sounds as though you intermittently breath normally in between these brief episodes. As stated above, anxiety can absolutely be associated with a subjective feeling of being short of breath or not breathing, and this sounds to be the most likely cause in your case as well. The best treatment for these symptoms, in that case, would be to treat the anxiety, and the shortness of breath should also resolve.
Again, without knowing your age, the rest of your medical conditions, what medications you are taking, or other information, it is difficult to accurately arrive at the correct diagnosis, and that is why it is so important for you to schedule an appointment with your doctor (and also so that he or she can begin treatment for your anxiety if that is the cause).