You can find various answers to this on the Web. If your doctor has advised against sex for some special reason, follow the advice. In the last month of pregnancy sex is not discouraged if both partners are comfortable with it. Sex after water has broken is discouraged. Some positions might be preferred.
Many can continue having sex all throughout the pregnancy unless there is a complication. However, in the last month, it can bring on contractions. Anything that stimulates the cervix can speed you faster toward labor. When I was pregnant and baby was late, having sex was one of the things my doctor suggested to try to get labor going. I did find sex not super comfortable during the last couple months. So, maybe find other ways to be intimate if that's the case. You can still be intimate but perhaps not business as usual. good luck