This is an important question to discuss with your primary care doctor
. Masturbation is a normal bodily function, and, generally speaking, it is not harmful to the body. Similarly, there is nothing specifically about withholding from ejaculation that is harmful to the body. Sometimes, with vigorous or prolonged masturbation or sexual intercourse, there can be a small amount of irritation inside the urethra, and this could cause a minor amount of soreness. However, as long as these symptoms are not severe or persistent, this is not usually a problem.
That being said, if you notice any severe pain in the penis or genitals, or any trouble or discomfort with urination, these might be signs of a more serious inflammation, and you would want to discuss this with your primary care doctor right away.
Also, these sorts of general health questions are exactly the kinds of things that you should feel free to talk with your primary care doctor about. An annual health physical is a great opportunity to have all of your general questions answered. Therefore, if you don't have a regular visit set up with your primary care doctor, now might be a good opportunity to schedule one. They will be able to answer all of your health questions.