How long after sex should I take a test?

Anna
Me and my boyfriend are trying to have a baby and we just had sex about 2 hours ago. I was wondering how long I should wait before taking a test?