you ovulate 14 days *before* your period, so if you have a regular cycle it's pretty easy to keep track of.
i know that sperm can survive for up to 5 days (i think it's 5...), so to be safe you should avoid having unprotected sex from about 5 days before you should ovulate to about 2 days after. if you have a regular 28 day cycle, you would avoid sex from days 10-17. though if you're ttc, you should aim for sex during that time and most people say that doing it every other day is best.
this is just what i've learned, it might not be 100% accurate but i know it's close.