testing pregnant?

Do I test 2 weeks after sex or when ?? Does it matter when u have sex or has to be on ovulating days I recently had a miscarriage on April 25 and had sex when I stopped bleeding recently he's been nutting inside so I'm I high risk of getting pregnant again or no ? ??