Sin incurs two punishments: eternal and temporal. The eternal punishment confines the soul to eternity in Hell, but the sacrament of Penance forgives the punishment The temporal punishment requires a sinner’s expiation or reparation for his sins, and remains after the sin is forgiven, as 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) identifies three major ways of expiation: prayer, fasting, and almsgiving. Any good work, sacrifice and patiently bearing our sufferings expiate sins (CCC1459-1460). Christ redeemed Humanity through Suffering and the Holy Spirit told me “your suffering is your treasure.” Refer to the article Interaction with the Holy Spirit.
The gaining of indulgences is another way of expiation (CCC 1471). The merits Christ gained were enough to expiate all sins, and his merits combined with the merits of Mary and the saints form the Spiritual Treasury of the Church (CCC 1476). The Church grants indulgences for the remission of temporal punishment from the treasury. A plenary indulgence remits all temporal punishment of a sinner, while a partial indulgence remits partial punishment. Refer to the article Plenary Indulgence.
If a sinner does not expiate all sins before he dies, he must complete expiation in Purgatory (CCC 1030), before he enters into Heaven. Catholics pray for the souls in Purgatory, because “it is a holy and beneficial thought to pray for the dead to be loosed from their sins.” (2 Macc 12:46)