How many days a must married couple refrain from intimacy after their baby is born?
Leviticus Ch. 12 says that it's 7 days if the baby is a boy, and 14 if a girl; (but she has to then immerse in mikvah, a ritual bath). (Then there's a lengthier stretch of time that she can't enter the Temple, but is permitted to her husband.)
Skip ahead to Leviticus Chapter 15. If a woman has a normal period (15:19) then she must abstain from her husband for seven days (counting from the start of the period), then take a ritual bath the next day, then she's fine. BUT (15:25), if the bleeding isn't "normal", she has to wait till it stops, then count seven clean days, then ritual bath.
By the year 400 or so, Judaism established that we don't always know exactly what's called "normal" bleeding or not, so to avoid problems, any menstrual-type bleeding requires cessation, then seven clean days, then a ritual bath before she is permitted to her husband once again. This applies to childbirth as well.
So practically today, it's end-of-bleeding (which I think is usually a few weeks) plus seven days, plus immersion.
My understanding is all laws aside, doctors today wouldn't recommend anything sooner than a few weeks, anyhow.
Aside from the seven days for a son and fourteen days for a daughter given in Tazria, it is normal to continue to bleed for weeks or even months following childbirth. One should certainly consult closely with one's rav to determine when the mother may begin counting seven clean days.
There is an established custom in some communities to separate for forty days following the birth of a son and for eighty days following the birth of a daughter, but there are those who condemn this custom as overly strict. Additionally, some authorities rule that one must separate from one's wife on the night of the forty-first day following the birth of a son and the night of the eighty-first day following the birth of a daughter. (Kitzur Shulchan Aruch 158:1-2)