Safest time to have sex

When is the safest time to have sex with less chances of getting pregnant? Before your period, while your on your period or after?