For non-Catholics becoming Catholics, confession is encouraged in the liturgical book “Rite of Christian Initation of Adults”, n. 482 (USA numbering):
“If the profession of faith and reception take place within Mass, the candidate, according to his or her own conscience, should make a confession of sins beforehand, first informing the confessor that he or she is about to be received into full communion. Any confessor who is lawfully approved may hear the candidate’s confession.”
(The Rites Volume One, Liturgical Press, 1990, ISBN: 0-8146-6015-0, page 277).
Generally non-Catholic Christians can go to the sacrament of confession in the circumstances of Canon 844 of the Code of Canon Law:
“§3. Catholic ministers administer the sacraments of penance, Eucharist, and anointing of the sick licitly to members of Eastern Churches which do not have full communion with the Catholic Church if they seek such on their own accord and are properly disposed. This is also valid for members of other Churches which in the judgment of the Apostolic See are in the same condition in regard to the sacraments as these Eastern Churches.
§4. If the danger of death is present or if, in the judgment of the diocesan bishop or conference of bishops, some other grave necessity urges it, Catholic ministers administer these same sacraments licitly also to other Christians not having full communion with the Catholic Church, who cannot approach a minister of their own community and who seek such on their own accord, provided that they manifest Catholic faith in respect to these sacraments and are properly disposed.
§5. For the cases mentioned in §§2, 3, and 4, the diocesan bishop or conference of bishops is not to issue general norms except after consultation at least with the local competent authority of the interested non-Catholic Church or community.”
From the Code of Canon Law, at
vatican.va/archive/ENG1104/_INDEX.HTM .