I used to get them constantly then someone told me I was probably allergic to Sodium Lauryl Sulfate, which is in most toothpastes. I switched to a SLS-free toothpaste and now I almost never get them. My son experienced the same thing.
I will share this far and wide with anyone I can in case it helps!