Not sure how it helps giving birth (give you more stamina maybe? Haha) but it should be safe all the way until you're in labour. I'd say go for it while you still can since after baby comes out there's not much chance for it 😜
Having sex can release oxytocin, a hormone that can trigger contraction. If your baby is overdue, sex is a way to induce labour.