Ideally (le-chatchila), one should not wash one’s mouth on the minor fasts, because there is concern that one might swallow drops of water. However, one who detects that his breath smells bad may wash out his mouth, because he has no intention to drink, only to clean his mouth. Still, he should be very careful not to swallow any water. One may use toothpaste in order to clean out his mouth thoroughly and remove a bad smell, if not doing so causes him distress.
Tish’a B’Av is a stricter fast, which entails a prohibition against washing oneself. Therefore, one should act more stringently and, unless it is very necessary, not rinse his mouth. Only someone who would be greatly distressed may wash out his mouth and brush his teeth, without toothpaste, even on Tish’a B’Av. On Yom Kippur, however, when one must fast according to Torah law, one should not be lenient.
. True, the Shulchan Aruch (567:3) writes that one should not rinse one’s mouth on a fast day, but many Acharonim, including the Mishnah Berurah (567:11), state that it is permitted, if not doing so would cause distress. And it is even permitted on Tish’a B’Av, if the suffering is great. We are more sensitive today, and refraining from washing out one’s mouth causes most people distress. Therefore, such people may wash their mouths. Regarding toothpaste, see Berachot 14a: “One who is fasting may taste [food], without any issue.” Most Rishonim understand that the Gemara is talking about tasting without swallowing, in order to know how the dish tastes [and whether it needs more salt or the like], but it is forbidden to swallow. There is also debate as to which fast day is at issue. According to the Rosh, the Gemara is talking about any communal fast (except Tish’a B’Av), and the Shulchan Aruch (567:1) agrees. Tosafot hold that the Sages permitted tasting only on personal fast days, not on communal ones. The Rama writes that the custom is to act strictly and not to taste anything on a fast day. However, the Mishnah Berurah (567:6) writes that one may be more lenient if [the tasting] is for the sake of a seudat mitzva (a religious meal). All the more so, one who suffers when he does not brush his teeth with toothpaste may act leniently. Perhaps even the Rama would agree with this, because the person has no intention to taste [the toothpaste], only to clean out his mouth. Tish’a B’Av is more stringent, because washing in general is forbidden on the day, included in which is washing one’s mouth. Nonetheless, someone who is greatly distressed may wash [his mouth], but without toothpaste, because even the Rosh who rules leniently on the issue of tasting food on a fast day forbids it on Tish’a B’Av. We rule even more strictly regarding Yom Kippur, because its prohibition is Torah-based, and one is forbidden by Torah law [to eat] even less than the proscribed amount [for which one receives punishment]. See further: Torat HaMo’adim 1:10-11, Mikra’ei Kodesh (Harari) 3:5, and Piskei Teshuvot 567:1.