First of all, it is to be noted that eating is different from tasting. It is not necessary for anyone to swallow something in order to taste it. It is the front part of the tongue that tastes. Therefore, it is permissible for a fasting person to taste the food, if necessary, and his fast is still valid so long as he does not deliberately swallow anything of it.
In his well-known book, Fiqh As-Sunnah, the late Azharite scholar Sheikh Sayyed Sabiq states the following: Ibn ‘Abbas ruling is that: ‘There is no problem with tasting liquid food or something you wish to purchase.
Sheikh M. S. Al-Munajjid, a prominent Saudi Muslim lecturer and author, adds: There is nothing wrong with a fasting person tasting the food if he needs to, as long as he tastes it with the tip of the tongue and then spits it out without swallowing anything.
But if the fasting person forgets and swallows it by mistake, there is no sin on him, and he should complete the fast. This is because the general rule of Shari`ah is that the person who forgets is excused. The Prophet (peace and blessings be upon him) said: “Whoever forgets that he is fasting and eats or drinks something, let him complete his fast, for it is Allah Who has fed him and given him to drink.” (Reported by Al-Bukhari and Muslim)