What is reverse sneezing:
https://www.vetinfo.com/reverse-sneezing-dogs.html
Reverse sneezing, also known as paroxysmal respiration or pharyngeal gag reflex, is common in dogs. Reverse sneezing is not actually a sneeze at all. Reverse sneezing is a spasm that occurs when the soft palate and throat become irritated. Most dogs may develop this problem with age, but some can have this condition their entire lives. Reverse sneezing is not a serious condition, and it rarely requires treatment.

Recognizing Reverse Sneezing:
During a spasm, dogs will extend their neck while gasping with a loud, forceful snorting sound. They usually turn their elbows outward and their eyes may bulge. The trachea becomes narrow and it’s more difficult to get a normal amount of air into the lungs. The chest expands as the dog tries harder to inhale.
Some owners may think their dog is choking, suffocating or even having a seizure during an episode, as the reverse sneezing may sound like the dog is inhaling sneezes. Each episode usually lasts two minutes or less, and normally end on their own and pose no threat to your dogs health.
Dogs appear normal both before and after an episode, with no after effects. Dogs do not lose consciousness, nor do they collapse. This phenomenon is usually harmless and, in most cases, does not require medical treatment.

Causes:
Pharyngeal spasms can be caused by various types of irritants and even some dog allergies. Dust, pollen, mites, household chemicals and cleaners, perfumes, viruses, nasal inflammation and post-nasal drip are some causes. Some triggers of reverse sneezing are rapid eating or drinking, exercise intolerance, pulling on the leash and excitement. It’s possible that sinusitis and other respiratory disorders cause episodes.
This condition is more common in small dogs, although any breed can experience it. Short-faced breeds such as Bulldogs, Boxers, Pugs, Boston Terriers and Shih Tzus are more prone to reverse sneezing. A genetic factor is suspected to be involved with these smaller breeds.

Treatment: 
Antihistamines are given if allergies are the root problem. Your veterinarian may use drugs if mites are in the laryngeal area. Gently massaging your dogs throat may help to stop the spasms. Covering the nostrils is sometimes effective because it makes the dog swallow, which can clear out whatever is causing the irritation. Try depressing the dog’s tongue if the episode does not end quickly, as this will open the mouth and aid in moving air through the nasal passages. Distract your dog by taking him outside for some fresh air. Offer him something to eat or drink.
The nasal passages and throat should be examined by your veterinarian if episodes become more severe or more frequent.

From another veterinarian (not involved with writing the above information): In megae dogs, it can result from acid or stomach contents irritating the back of the throat/nose. In non-megae dogs, it seems to occur from not only the same reasons, but, in those dogs who may have sinus or dental infections. There are some dogs, also, who “reverse sneeze” when they are excited, for some unknown reason. Unless it is interfering w/ life, or is becoming very frequent, it seldom requires treatment (antibiotics and/or antihistamines are most common treatments).