In question 50005 we have already stated that if a breastfeeding mother or pregnant woman fears for herself or her child, then it is better for her not to fast and fasting is makrooh in her case. Indeed some of the scholars said that if she fears for her child it is haraam for her to fast and she should not fast, because she has no right to do something that would harm her child.
If the child is able to do without his mother’s milk then she should fast because there is no need for her not to fast in this case.
Al-Mirdaawi said in al-Insaaf (7/383):
If the child is able to do without his mother’s milk, it is not permissible for her not to fast.
If what you mean in your question by “stop breastfeeding my child” is weaning him, that depends on the child’s situation. If he will be harmed by that, it is not permissible to do it; if he will not be harmed by it, then there is nothing wrong with weaning him, after you consult with his father and agree on that, because Allaah says (interpretation of the meaning):
“The mothers shall give suck to their children for two whole years, (that is) for those (parents) who desire to complete the term of suckling, but the father of the child shall bear the cost of the mother’s food and clothing on a reasonable basis. No person shall have a burden laid on him greater than he can bear. No mother shall be treated unfairly on account of her child, nor father on account of his child. And on the (father’s) heir is incumbent the like of that (which was incumbent on the father). If they both decide on weaning, by mutual consent, and after due consultation, there is no sin on them”
The phrase “If they both decide on weaning” means weaning the child from the breast, i.e., weaning him from his mother’s milk to other kinds of food. “by mutual consent” means, before two years have passed. “there is no sin on them” means, in weaning him, because Allaah has stipulated that the period of breastfeeding should be two years, except when the parents agree on a shorter period, so long as that is not harmful to the child. That is permissible according to this statement.
Ibn Jareer narrated in al-Tafseer (3913) that Sufyaan al-Thawri said: If the father wants to wean him before two years, and his wife does not agree, then he does not have the right to enforce that. If the woman says, I want to wean him before two years, but the father says no, then she does not have the right to wean him unless the father approves and they reach an agreement. If they reach an agreement before two years, they may wean him, but if they disagree then they should not wean him before two years, as Allaah says: “If they both decide on weaning, by mutual consent, and after due consultation”.
But if what is meant is switching the child from breast milk to formula, this affects the interests of the child by denying him natural breast milk, and the importance of natural breastfeeding to the child has been proven beyond any shadow of a doubt. In this case the mother should not give up natural breastfeeding in order to fast, because formula milk cannot completely replace breast milk. The importance of breastfeeding is sufficient excuse for her not to fast. See also question no. 20759.
And Allaah knows best.