Sex after miscarriage?

How long did your doctors advise you not to have sex after a d&c? My doctor said to avoid sex for 3 weeks after the miscarriage and use a condom every time up until the next period comes in order to avoid infection. I for sure do not feel like doing anything now, one week after the d&c as I still feel cramps and I am really depressed...but as I did <a href="https://glowing.com/glow-fertility-program">IVF</a> to get pregnant I haven't had sex in months...so I am really excited to start a normal sex life again after these last difficult couple of months.