The Catechism in Questions & Answers

507. What is the relationship between forgiveness of sins and Holy Communion?

Forgiveness of sins is closely related to Holy Communion, since they are both based on the sacrifice of Jesus Christ.
The sacrament of Holy Communion does not at the same time effect the forgiveness of sins, however. The forgiveness of sins is necessary so that the believers can subsequently partake worthily of Holy Communion, that is, in a state in which they have been cleansed of sin.