If it is diagnosed as oral thrush, be careful of the type of medication you are put on. Nystan liquid drops for oral thrush have a lot of sugar in the solution. Why?!! Surely this is just feeding the yeast infection it's supposed to be killing! It is what my Mother has from the doctor and it does not help her at all. We are trying for fluconazole or another oral antifungal instead.
If it's not oral thrush and just mouth ulcers, then I used to get these and these can be caused by a virus that is with us constantly but only infects when we are under a stress, have a lower immune resistance and may be deficient. I used to get them, then read about zinc rich foods and perhaps take a chelated zinc (zinc+amino acid so human can absorb it) such as zinc gluconate supplement with a meal each day. It's the mineral that helps keep skin integrity and healing, so helps you get better from ulcers quicker.
Metformin itself can stop you absorbing certain nutrients from food, eg B12 and folate. Deficiencies of these may cause irritation on the skin. You might need these as supplements - ask your Doctor.