Are you asking how long sperm lives in your system after sex, or how long to wait before taking a home pregnancy test?
After sex, sperm can live in your system up to five days or maybe six. If you pop out an egg on any of those days, it might get fertilized and then later it might implant in the uterus, and then you would be pregnant. After two weeks from ovulation (around the time your period is due) you can test with a sensitive or early-results home test.
It can take up to 2 weeks give or take for the process of the sperm to meet the egg. the soonest your hormone levels will be high enough to test for with an at home pregnancy test will be 4-6 weeks after you have sex.