All perfect praise be to Allaah, The Lord of the worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad, sallallaahu ‘alayhi wa sallam, is his slave and messenger.
If, by your question, you mean the ruling on paying Zakatul-Fitr on behalf of the fetus, then this is not obligatory according to the opinions of most scholars. Ibn Al-Munthir reported that the scholars unanimously agreed on this ruling. Hanbali scholars considered it recommended since ‘Uthmaan ibn ‘Affaan used to pay Zakatul-Fitr on behalf of a fetus. Abu Qulaabah said, “They preferred paying Zakatul-Fitr on behalf of young and old family members, even the fetus still in the mother’s womb.”
If you meant offering charity in all cases, then there are no religious texts that forbade offering charity on behalf of a fetus. ‘Uthmaan ibn ‘Afaan and other Companions used to do that, which indicates the permissibility of offering charity on behalf of a fetus as it indicated treating them as those whose lives have begun. It is permissible to give charity on behalf of a living person, although it is better to confine this to Zakatul-Fitr, as the reported traditions were not in other than this regard.
Allaah Knows best.