Are the times I should avoid sex while pregnant?

Seldom. There are few instances when avoidance of sex are advised during pregnancy. Placenta previa is an infrequent condition, diagnosed by ultraosund, when sex is forbidden due to risk of hemorrhage. Otherwise, various conditions, such as early contractions, or when bleeding has occurred, may lead your OB to recommend abstinence for a time.
Yes. First, sex shouldn't hurt so if it does, you should avoid sex until you can be examined. If you have bleeding in the first 14 weeks, you should avoid sex. If you have a previa or other placental problem, you should avoid. If you have been diagnosed with a sexually transmitted disease, you should abstain until your partner is treated too.