It is generally safe to masturbate during pregnancy. However, you should always talk to your doctor first if you have any concerns. They can advise you on any risks associated with the activity and make sure that it is safe for your individual situation.