What happens if a female is sentenced to death while pregnant. Would the execution be delayed until she gave birth? Or even longer (e.g., until the child is weaned)?
While this is difficult without a specific state, as states are responsible for criminal law, 18 U.S. Code § 3596 (b) states that:
(b) Pregnant Woman.—
A sentence of death shall not be carried out upon a woman while she is pregnant.
It is likely (though I have not checked) that States will have similar legislation in place, for example, California (Cal Penal Code § 3706):
3706. If it is found that the female is not pregnant, the warden must execute the judgment; if it is found that she is pregnant the warden must suspend the execution of the judgment, and transmit a certified copy of the finding and certificate to the Governor. When the Governor receives from the warden a certificate that the defendant is no longer pregnant, he must issue to the warden this warrant appointing a day for the execution of the judgment.
This defence dates back to English common law - 14th century English common law.
It's also worth noting that the International Covenant on Civil and Political Rights Article 6(5), which the vast majority of countries are party to states:
Sentence of death shall not be imposed for crimes committed by persons below eighteen years of age and shall not be carried out on pregnant women.
Although treaty reservations may be made, it's unlikely to be a valid reservation, as states can't make a reservation with respect to a prohibition. In short, most countries and jurisdictions are likely to have similar laws in place.
Although this question is tagged as "United States" and the accepted answer addresses the issue there, I would like to address feewet's comment "Might be interesting to address the question also to other countries with capital punishment that tend to carry out those sentences far more expeditiously than the U.S".
In the world famous cases of Amina Lawal and Safiya Hussaini, Nigerian women condemned for adultery in 2002, execution was delayed until end of breastfeeding, although conviction was overturned in the end. According to New York Times, "Ms. Lawal was to be executed as soon as she had finished weaning the child".
Obviously, a woman would not be executed while pregnant, but Title 18 U.S. Code § 3596 (b) does not make mention of further procedures to ensure the woman's life. This leads one to believe that the legal connotation is that the woman would be executed after giving birth, or that state would enforce an abortion. In any case, the code states that once proof of either birth or abortion occurred, the sentence of death is then re-instated.