Generally, the Church declines to comment whether any given person is in Heaven or not — at least not without a laborious inquiry and at least two confirmed miracles — but there are paragraphs in the Catechism we can use to try and understand how someone outside the Church might attain state of grace and retain it.
977 Our Lord tied the forgiveness of sins to faith and Baptism: "Go into all the world and preach the gospel to the whole creation. He who believes and is baptized will be saved."Mk 16:15–16 Baptism is the first and chief sacrament of forgiveness of sins because it unites us with Christ, who died for our sins and rose for our justification, so that "we too might walk in newness of life."Rom 6:4; Cf. 4:25
978 "When we made our first profession of faith while receiving the holy Baptism that cleansed us, the forgiveness we received then was so full and complete that there remained in us absolutely nothing left to efface, neither original sin nor offenses committed by our own will, nor was there left any penalty to suffer in order to expiate them.... Yet the grace of Baptism delivers no one from all the weakness of nature. On the contrary, we must still combat the movements of concupiscence that never cease leading us into evil "Roman Catechism I, 11,3
979 In this battle against our inclination towards evil, who could be brave and watchful enough to escape every wound of sin? "If the Church has the power to forgive sins, then Baptism cannot be her only means of using the keys of the Kingdom of heaven received from Jesus Christ. the Church must be able to forgive all penitents their offenses, even if they should sin until the last moment of their lives."Roman Catechism I, 11,4
980 It is through the sacrament of Penance that the baptized can be reconciled with God and with the Church:
Penance has rightly been called by the holy Fathers "a laborious kind of baptism." This sacrament of Penance is necessary for salvation for those who have fallen after Baptism, just as Baptism is necessary for salvation for those who have not yet been reborn.Council of Trent (1551): DS 1672; Cf. St. Gregory of Nazianzus, Oratio 39,17: PG 36,356
So when a person is first baptised, their sins — both original and voluntary — are removed from them. And, as the Church teaches, any one — Catholic or not — can effect a valid Baptism if they recite the correct formula with the correct intention:
1256 The ordinary ministers of Baptism are the bishop and priest and, in the Latin Church, also the deacon.Cf. CIC, can. 861 # 1; CCEO, can. 677 # 1 In case of necessity, any person, even someone not baptized, can baptize, if he has the required intention. the intention required is to will to do what the Church does when she baptizes, and to apply the Trinitarian baptismal formula. the Church finds the reason for this possibility in the universal saving will of God and the necessity of Baptism for salvation.Cf. 1 Tim 2:4
However, and this is important, Baptism does not remove one's inclination to sin; and after one sins again, they lose their state of grace and thereafter it cannot be restored to them without the Sacrament of Penance.
The Sacrament of Penance, on the other hand, cannot be validly conferred but by a Catholic priest (cf. Canon 965) and only to baptised Catholics or Orthodox, and ordinarily by individual confession. So, barring specific Divine intervention, a person who is baptised and subsequently sins cannot regain their state of grace unless they are received into the Catholic Church — or another Church with valid Sacraments — and subsequently receives the Sacrament of Penance.
Therefore, a Protestant who dies immediately or nearly immediately after being baptised can generally be considered as having died in a state of grace, even though they might have died outside the fold of the Church. Otherwise, a person will generally sin again and lose their state of grace, and be unable to regain it because the Sacrament of Penance cannot validly be conferred upon them — not least because they generally do not believe in the efficacy of that Sacrament.
That being said, the Church will hesitate to declare that these people are definitely damned because "with God, all things are possible" (Mt. 19:26) and it may be that God will, in His mercy, effect extraordinarily that absolution which He has given ordinarily to His Church through the Sacrament of Penance. Though because such a grace is extraordinary, it must not be counted upon, and the Church calls upon her separated brethren to come into communion and gain ordinary access to the wellspring of graces that is the Sacrament of Penance.