There is no safe time to have unprotected sex and since he ejaculated right next to your vagina,
that puts
you at risk as well for pregnancy.
You can take a home pregnancy test 2 weeks after having sex or after a missed period, and you should get an accurate result. The chance of getting pregnant from this is not very high, so try not to stress yourself out. Though in the future, use this as a learning lesson to never do again.