Thanks for sharing your concern.
you have been advised root canal treatment
that shows, the concerned tooth is infected and involved pulpally.
If left untreated it will cause recurrent problems like pain and abscess.
An ulcer can develop due the following.
Any jagged tooth edges.
especially vitamin B.
Any bacterial and fungal infections due to poor oral hygiene
Food products and chemicals.
You must visit your dentist
and get it examined.so that other reasons can be ruled out except the actual cause.
For pain relief you can apply dologel locally.
But exact diagnosis and treatment is suggested.
Hope it helps.