When to take a test

How long after unprotected sex can I take a test and it be accurate? It's been about two weeks maybe three. I'm having some bleeding. Normally my periods are heavier than this, I have had headaches and breast soreness a few days ago.