If you have unprotected sex or if there is an accident like a condom splitting then you can take emergency contraception to prevent pregnancy. The earlier you do this the better.
You should also get tested for a sexually transmitted infection if you and your partner haven’t done this already.