Sin incurs two punishments: eternal and temporal. The eternal punishment confines the soul to an eternity in hell, but this punishment is remitted through the forgiveness of sins. The temporal punishment requires a person to expiate, or make reparation for his sins, and remains even after the sin is forgiven. Unlike eternal punishment, temporal punishment remains until it is expiated, and is God’s method of loving discipline: “Do not disdain the discipline of the Lord… for whom the Lord loves, he disciplines…” (Hebrews 12:5)
The Catholic Church Cathecism (CCC) has traditionally identified three major ways to expiate sins: prayer, fasting, and almsgiving. Any good work or sacrifice expiates sin, as well as patiently bearing our sufferings and offering them up in satisfaction for our sins (CCC 1459-1460). Christ redeemed Humanity through Suffering and the Holy Spirit Himself told me “your suffering is your treasure“. Refer to the article Interaction with the Holy Spirit.
There is one more method of expiation, and that is the gaining of indulgences. An indulgence is the remission of temporal punishment due to sins already forgiven (CCC 1471). The merits gained by Christ were enough to expiate all sins, and these merits, combined with the merits of Mary and the saints form the Spiritual Treasury of the Church (CCC 1476). It is from this treasury that the Church grants indulgences for the remission of temporal punishment, when a certain prayer or work is performed. A plenary indulgence remits all of one’s punishment, while a partial indulgence remits a portion of one’s punishment. Refer to the article Plenary Indulgence.
If one has not fully expiated his sins before dying, one must expiate his sins in purgatory (CCC 1030), before advancing to Heaven. Catholics have always prayed for the souls in purgatory, for “it is a holy and wholesome thought to pray for the dead, that they may be loosed from their sins.” (2 Macc. 12:46)