It actually looks like a slight chemical burn. Because it is in the areas that touch your teeth, I am wondering if you have used a new dental product like a new toothpaste, dental floss, mouthwash, etc. If so, this is likely the culprit. If not, then it could be caused be too much acid in the mouth as can happen with consumption of acidic foods and drinks and some spices. This can include coffee, tea, soda, citrus fruits or juices, peppers, cinnamon, chili, hard candies, suckers, mints, or cinnamon flavored chewing gum.
Once you eliminate the culprit, this should heal fairly quickly. To calm the area a bit and facilitate quicker healing, try rinsing with warm salt-water. Avoid all those acidic things, even if they were not the cause, until the area has healed.
This same thing happened to me after a dental visit. It turned out to be an allergic reaction to the fluoride treatment they put on my teeth.