The most famous example of a posthumous monarch is Shapor II the Great, "King of Kings of Iran and of Non Iran, Child of the Sun and Moon and Cousin of the Stars" reigned 309-379 AD, who allegedly reigned before he was born (and of course a couple of decades before he ruled). The story is that despite having older half brothers, astrologers luckily predicted he would be male, and he was crowned while still in the womb.
His successor was his older half brother Ardashir II, who reigned from 379-383, and then Shapor II's son Shapor III (383-388).
And there was Ladislaus Posthumous (22 February 1440 – 23 November 1457), King of Hungary & Croatia 1440 and 1444-1453 King of Bohemia and Duke of Austria, Son of Albert II (1397-27 October 1439), King of the Romans, King of Hungary & Bohemia and Duke of Austria.
In most cases when a deceased king's widow was believed to be pregnant, a regent was appointed until such time as the child was either born or not. I don't think that I have ever heard of a monarch having to step down when a posthumous child was born.
A posthumous birth[clarification needed] has special significance in the case of hereditary monarchies following primogeniture. In this system, a monarch's own child precedes that monarch's sibling in the order of succession. In cases where the widow of a childless king is pregnant at the time of his death, the next-in-line is not permitted to assume the throne, but must yield place to the unborn child, or ascends and reigns until the child is born. In monarchies that follow male-preference cognatic primogeniture, the situation is similar where the dead monarch was not childless but left a daughter as the next-in-line, as well as a pregnant widow. A posthumous brother would supplant that daughter in the succession, whereas a posthumous sister, being younger, would not. Similarly, in monarchies that follow agnatic primogeniture, the sex of the unborn child determines the succession; a posthumous male child would himself succeed, whereas the next-in-line would succeed upon the birth of a posthumous female child.
But they don't give any examples of a monarch who started to reign and then had to give up the throne to a posthumous child of the previous monarch. I think in most cases an interregnum would be preferable to enthroning a king and then making him step down in a few months.
Bohemia had a interregnum of 14 years between the death of Albert and the accession of Ladislaus Posthumous, so an interregnum of less than nine months waiting for a posthumous child to be born would not be too long.
This discussion of the accession proclamation of Queen Victoria in 1837 points out that according to UK law Victoria had to succeed immediately because the throne can never be vacant for an instant. And thus the paradox that she might have been dethroned if her uncle's widow gave birth to a posthumous child with superior succession rights to her.
They mention that in France a regent ruled for 163 days between the death of Louis X and the birth of his son John I. They say that can't happen in the UK because a regent must rule in the name of some monarch in the UK.
I suggest that the solution could be to select an eternal monarch (or set) of the UK that the living monarch would do homage to once a year. thus they could have a regency in the name of the eternal monarch during any period when a posthumous heir might be born. And if a posthumous heir is born they can continue the regency in his or her name until her majority.
Norway had an eternal monarch for centuries during the Middle Ages.
Saint Olaf II Haraldsson (995-1030), king of Norway from 1015 to 1028, was killed at the Battle of Stiklestad on 29 July 1030. He was later granted the title of Rex Perpetuus Norvegiae, Eternal of Norway. According to the Norwegian La of succession of 1163 every king of Norway since St. Olaf's son Magnus II was a vassal of St. Olaf.
So maybe the UK should create a college of joint eternal soverigns that the King or Queen of the United Kingdom of Great Britain and Northern Ireland can be the theoretical vassal of.
For Northern Ireland the monarch of the UK could do homage once a year in Belfast to Edward V, King of England and Lord of Ireland (and heir of the Earls of Ulster), who was probably murdered by one of the monarch's predecessors and/or ancestors.
For England, the monarch of the UK could do homage once a year to Edward V (1470-1483?) and Arthur Duke of Brittany (1187-1203?) probably murdered by one of the monarch's predecessors and/or ancestors, and Arthur's sister Eleanor of Brittany (c.1184-1241) imprisoned by one of the monarch's predecessors and ancestors. Note Arthur of Brittany as born posthumously.
For Scotland the monarch of the UK could do homage to William Douglas (c. 1424-1440) 6th Earl of Douglas and his younger brother David, treacherously murdered at the Black Dinner in the name of one of the monarch's predecessors and ancestors, and to the unnamed heiress of the Meic Uilleim claimants of the Scottish throne who was brutally murdered in 1229 or 1230 by officials of one of the monarch's predecessors and ancestors.
And so, if a monarch of the UK dies with the possibility of having a posthumous child, a regent can perform the monarch's duties in the name of the eternal monarchs of England, Scotland, and Northern Ireland, until such time as the posthumous child is or is not born.
Anyway, I have not found any examples of monarchs who had to abdicate when a posthumous child of a previous monarch was born.