Catechism of the Catholic Church:
Offenses against chastity
[2351 is about lust]
2352 [link] By masturbation is to be understood the deliberate stimulation of the genital organs in order to derive sexual pleasure. “Both the Magisterium of the Church, in the course of a constant tradition, and the moral sense of the faithful have been in no doubt and have firmly maintained that masturbation is an intrinsically and gravely disordered action.” [138: CDF, Persona humana 9] “The deliberate use of the sexual faculty, for whatever reason, outside of marriage is essentially contrary to its purpose.” For here sexual pleasure is sought outside of “the sexual relationship which is demanded by the moral order and in which the total meaning of mutual self-giving and human procreation in the context of true love is achieved.” [139: CDF, Persona humana 9]
[2353-2357 are about fornication, pornography, prostitution, rape, and homosexual acts]
SACRED CONGREGATION FOR THE DOCTRINE OF THE FAITH
DECLARATION ON CERTAIN QUESTIONS
CONCERNING SEXUAL ETHICS [link]
The traditional Catholic doctrine that masturbation constitutes a grave moral disorder is often called into doubt or expressly denied today. It is said that psychology and sociology show that it is a normal phenomenon of sexual development, especially among the young. It is stated that there is real and serious fault only in the measure that the subject deliberately indulges in solitary pleasure closed in on self (“ipsation”), because in this case the act would indeed be radically opposed to the loving communion between persons of different sex which some hold is what is principally sought in the use of the sexual faculty.
This opinion is contradictory to the teaching and pastoral practice of the Catholic Church. Whatever the force of certain arguments of a biological and philosophical nature, which have sometimes been used by theologians, in fact both the Magisterium of the Church – in the course of a constant tradition – and the moral sense of the faithful have declared without hesitation that masturbation is an intrinsically and seriously disordered act.  The main reason is that, whatever the motive for acting this way, the deliberate use of the sexual faculty outside normal conjugal relations essentially contradicts the finality of the faculty. For it lacks the sexual relationship called for by the moral order, namely the relationship which realizes “the full sense of mutual self-giving and human procreation in the context of true love.”  All deliberate exercise of sexuality must be reserved to this regular relationship. Even if it cannot be proved that Scripture condemns this sin by name, the tradition of the Church has rightly understood it to be condemned in the New Testament when the latter speaks of “impurity,” “unchasteness” and other vices contrary to chastity and continence.
Sociological surveys are able to show the frequency of this disorder according to the places, populations or circumstances studied. In this way facts are discovered, but facts do not constitute a criterion for judging the moral value of human acts.  The frequency of the phenomenon in question is certainly to be linked with man’s innate weakness following original sin; but it is also to be linked with the loss of a sense of God, with the corruption of morals engendered by the commercialization of vice, with the unrestrained licentiousness of so many public entertainments and publications, as well as with the neglect of modesty, which is the guardian of chastity.
On the subject of masturbation modern psychology provides much valid and useful information for formulating a more equitable judgment on moral responsibility and for orienting pastoral action. Psychology helps one to see how the immaturity of adolescence (which can sometimes persist after that age), psychological imbalance or habit can influence behavior, diminishing the deliberate character of the act and bringing about a situation whereby subjectively there may not always be serious fault. But in general, the absence of serious responsibility must not be presumed; this would be to misunderstand people’s moral capacity.
In the pastoral ministry, in order to form an adequate judgment in concrete cases, the habitual behavior of people will be considered in its totality, not only with regard to the individual’s practice of charity and of justice but also with regard to the individual’s care in observing the particular precepts of chastity. In particular, one will have to examine whether the individual is using the necessary means, both natural and supernatural, which Christian asceticism from its long experience recommends for overcoming the passions and progressing in virtue.
19. Cf. Leo IX, letter “Ad splendidum nitentis,” in the year 1054 DS 687-688, decree of the Holy Office, March 2nd, 1679: DS 2149; Pius XII, “Allocutio,” Oct 8th, 1953 AAS 45 (1953), pp. 677-678; May 19th, 1956 AAS 48 (1956), pp. 472-473.
20. “Gaudium et Spes,” 51 AAS 58 (1966), p. 1072.
21. “. . . if sociological surveys are useful for better discovering the thought patterns of the people of a particular place, the anxieties and needs of those to whom we proclaim the word of God, and also the opposition made to it by modern reasoning through the widespread notion that outside science there exists no legitimate form of knowledge, still the conclusions drawn from such surveys could not of themselves constitute a determining criterion of truth,” Paul VI, apostolic exhortation “Quinque iam anni.” Dec 8th 1970, AAS 63 (1971), p. 102.