The Catechism of the Catholic Church defines a mortal sin (a sin that destroys charity in the soul) as “a sin whose object is grave matter and which is also committed with full knowledge and deliberate consent.”
In his 1930 encyclical Casti Connubii, Pope Pius XI taught that contraception is grave matter:
Any use whatsoever of matrimony exercised in such a way that the act is deliberately frustrated in its natural power to generate life is an offense against the law of God and of nature, and those who indulge in such are branded with the guilt of a grave sin (sec. 56; emphasis added).
The Congregation for the Doctrine of the Faith, with the approval of Pope St. Paul VI, also taught that contraception constitutes grave matter in its 1975 Declaration on Certain Questions Concerning Sexual Ethics Persona Humana. After stating that a person sins mortally when he chooses “something which is seriously disordered,” the declaration teaches:
Now, according to Christian tradition and the Church’s teaching, and as right reason also recognizes, the moral order of sexuality involves such high values of human life that every direct violation of this order is objectively serious (sec. X; emphasis added).
What does the declaration have in mind for such a violation? The declaration footnotes section 14 of Humane Vitae where Pope St. Paul VI condemns contraception. Therefore, according to Persona Humana, contraception is objectively serious or an object of grave matter.
So, if someone contracepts having full knowledge that such an act is grave matter, and deliberately consents to it, such a person will incur the guilt of mortal sin.