Coconut oil is safe to use as a lubricant for masturbation and sex but if you're having sex with a woman you should only use Coconut Oil as a lube if the woman is not prone to Yeast Infections or other vaginal infections.
If the woman is prone to Yeast infections or the other vaginal infections then you should avoid using Coconut Oil as a lube.
Olive oil is the most safest natural oil to use as a lube for both sex and masturbation by men.