A Pidyon Ha’ben is required in the case of the birth of a boy who is both a "Bechor" (firstborn) and a "Peter Rehem" (first child to exit the mother’s womb through the birth canal).
Accordingly, if a woman’s first child was born via a Caesarean section, he does not require a Pidyon Ha’ben, since although he is a "Bechor," he is not a "Peter Rehem." If the woman then conceives and delivers a second boy naturally, that child also does not require a Pidyon Ha’ben, because although he is the "Peter Rehem" – the first to pass through the birth canal – he is not a "Bechor." This is the ruling of the Shulhan Aruch (Yoreh De’a 305).
If a non-Jewish woman converted to Judaism after having delivered a child or several children, and she then marries a Jewish man and delivers a firstborn son, that boy does not require a Pidyon Ha’ben. Although he is the mother’s first child after her becoming a Jewess, nevertheless, he is not her biological "Peter Rehem," and so the Pidyon Ha’ben obligation does not apply.
If, however, she did not have any children before converting to Judaism, but she was pregnant at the time of her conversion, and that baby is a boy, he requires a Pidyon Ha’ben, even though the conception occurred before the mother’s conversion.
If a woman conceived and then miscarried, Heaven forbid, within forty days of conception, and she then conceives again and delivers a baby boy, that boy requires a Pidyon Ha’ben. Since the first pregnancy did not last for forty days, that fetus is not considered to have been viable, and therefore the next child is considered a "Peter Rehem." If, however, the miscarriage occurred after forty days since the conception, then the status of the next child depends on how developed the first fetus was at the time of the miscarriage. The Rama (Rav Moshe Isserles of Cracow, 1530-1572) writes that if the bones were already formed before the miscarriage, then the fetus was considered viable, and is thus deemed the firstborn, such that the next child does not require a Pidyon Ha’ben. If, however, the first fetus’ bones had not yet been fully formed, then even if the miscarriage occurred eight weeks or more after conception, the next child would be considered a firstborn and would require a Pidyon Ha’ben. This is the ruling accepted by Hacham Ovadia Yosef.
Given the difficulty in ascertaining when precisely a fetus reaches this stage, a competent Halachic authority must be consulted in any case where a woman miscarries, Heaven forbid, early in her first pregnancy, in order to determine the status of the next child.
Summary: If a woman’s first child is born via a Caesarean section, he does not require a Pidyon Ha’ben, and the second child likewise does not require a Pidyon Ha’ben, even if he is born naturally. If a woman converts to Judaism after having giving birth to a child or several children, her first child as a Jewess does not require a Pidyon Ha’ben. If she converted during her first pregnancy, and then delivered a boy, he requires a Pidyon Ha’ben. If a woman miscarried, Heaven forbid, in the early stages of her first pregnancy, a competent Halachic authority must be consulted to determine whether her next child requires a Pidyon Ha’ben, as this depends on the stage of development reached by the first fetus before the miscarriage.