When taking a pregnancy test it's best to wait until you miss your period but if you don't want to wait for that then you can take a pregnancy test 2 weeks after having sex.
Taking a pregnancy test any earlier than 2 weeks won't give you any good results.