Having fillings and applying medicine to the teeth does not affect the fast
That does not invalidate the fast so long as you do not deliberately swallow any of these materials. If it is possible to do that at night, that will be better and more on the safe side with regard to your fast.
Shaykh Ibn Baaz (may Allaah have mercy on him) was asked (15/285): If a person has a toothache and he goes to the dentist, and he does some cleaning or a filling or pulls out one of his teeth, does that affect his fast, or if the dentist gives him an injection to numb his tooth, does that affect his fast?
The things mentioned in the question do not affect the validity of the fast, rather that is excused. But he has to be careful to avoid swallowing any of the medicine or blood. Similarly, the injection mentioned does not invalidate the fast either, because it is not like food and drink, and the basic principle is that the fast remains valid. End quote.