You should be okay to masturbate and have sex all the way up until your water breaks, unless your doctor tells you otherwise. Yes, orgasms do cause uterine contractions, but unless your body and baby are ready they won't be strong enough to start labor.