What can I do to stop masturbating?

Happy marriage. But don't do this until you are completely sure you have found that one special person who's right for you. Until then, entertaining yourself will help you learn about your mind and body to prepare you for that happy time. It'll keep you comfortable and able to focus on life. You might talk with your personal physician -- or maybe even dad.