Please help!!

I know people say that there's a higher chance of getting pregnant while fertile. However can one get pregnant even when not fertile? Let's say I got off my period 2 days ago and had unprotected sex yesterday, can I still get pregnant? I was taking birth control pills but stopped taking them about a week ago. How soon should I take a test?