How long after a miscarriage can you have sex ?

I’m just about done bleeding and I was told I couldn’t have sex for a while due to infection but my obgyn never gave me an exact time?