In Orthodox Judaism the act of extracting semen in vain is, point blank, forbidden in the Midrash (an ancient commentary which is part of the Hebrew Scriptures) and Talmud (the body of the Rabbinic Judaism civil and ceremonial law, it is also traditionally known as Shas). Male masturbation is forbidden because it is seen unnecessary waste of semen and the Talmud likens this close to the act of murder. The act of discharge of semen is the (or one of) gravest sin in the Torah. As far as female masturbation goes it does not prohibit or discourage it. Although if there was something negative to say, some authorities may consider female masturbation to cause “impure thoughts”! The main reason for male masturbation carrying this severity is because it does not involve the release of the seed.
The most common form of Buddhism ethics is the ‘Five Precepts’ and the ‘Eightfold Path’ both of these lean towards saying that one some follow the right view and experience pleasures. The general rule intended to regulate behaviour or thought takes the form of voluntary, personal undertakings, not divine or mandate. The third of the Five Precepts is to ‘refrain for committing or doing sexual misconduct’. But what does define, without going into too much detail, ‘sexual misconduct’ is hazy and disputable each Buddhism school has different interpretations of the Five Precepts. So some believe that masturbation is therapeutic for the mind and body, some think it is a serious offence and others just think it is harmless and permissive.