Oooh that happens to me all the time! I went to the doctor and he told me that although it's not a serious condition it can get very annoying and painful. It's due to bacteria that are in our mouth's, so aside from keeping good dental hygiene you can try a mouth wash that will help with the pain and ensure the healing as well as prevent the infection from happening again, the mouth wash is called Artroben and you should be able to find it at an over the counter pharmacy for under 10 dlls.
Hope this helps and hope you feel better!
Rinse your mouth out with some warm salt water..... the salt water will ensure that your mouth would heal
It will heal quickly if you don't play with it. Swish salt water in your mouth for 30 seconds or so 3-4 times daily.