Yes, it is permissible to treat one’s teeth and apply paste and the like to the gums whilst fasting, but that is subject to the condition that you do not swallow it.
In the book Seventy Issues related to Fasting, it says:
There are some things that do not invalidate the fast, some of which we will mention by way of example:
1.Tablets that are placed under the tongue to treat angina and other conditions - so long as one avoids swallowing anything that reaches the throat.
2.Dental fillings, tooth extractions, cleaning of the teeth, use of siwaak or toothbrush - so long as one avoids swallowing anything that reaches the throat.
3.Rinsing, gargling or applying topical mouth sprays - so long as one avoids swallowing anything that reaches the throat.
Similarly there is nothing wrong with having an operation during the day in Ramadaan under anaesthetic, so long as the anaesthetic will not last all day, i.e., from dawn until sunset, because the ruling on anaesthesia in this case is the same as the ruling on sleep.
See also Question no. 12425.