Is it ok to have sex throughout pregnancy?

Generally. Unless there are particular problems with the pregnancy, it shold be safe to have sex during pregnancy. Listen to your obstetrician and if there are issues with bleeding, premature labor or other significant problems with the pregnancy, then sex should not be an issue.