Can mastrubation cause the deficiency of vitamins D3 & B12?

No. I'm sorry somebody told you this. One of the cults has claimed for decades that enjoying your body causes loss of various nutrients in the semen. This is totally made up to frighten young people. It won't make you bald, stupid, an unfit husband / father, blind, or anything else. Thanks for letting me set the record straight.
Here are some ... My 45-yr study and practice in medicine fail to incite an imagination to link deficiency of vitamin D3 & B 12 with masturbation. This Q is provocative. However, depriving exposure to sunlight and adequate intake of nutrition from sex overindulgence & obsession will in time affect these two vitamins' absorption and generation, but very unlikely. Nonetheless, take healthy lifestyle as the core of ..