There are two 'hearts' that Paul is writing about in Ro 2.
The 'hard and impenitent' heart...:
5 but after thy hardness and impenitent heart treasurest up for thyself wrath in the day of wrath and revelation of the righteous judgment of God;
6 who will render to every man according to his works:
...and the circumcised heart with the law written upon it:
13 for not the hearers of the law are just before God, but the doers of the law shall be justified:
14 (for when Gentiles that have not the law do by nature the things of the law, these, not having the law, are the law unto themselves;
15 in that they show the work of the law written in their hearts, their conscience bearing witness therewith, and their thoughts one with another accusing or else excusing them);
29 but he is a Jew who is one inwardly; and circumcision is that of the heart, in the spirit not in the letter; whose praise is not of men, but of God.
God renders to each of these hearts according to (not because of) their works.
7 to them that by patience in well-doing seek for glory and honor and incorruption, eternal life:
8 but unto them that are factious, and obey not the truth, but obey unrighteousness, shall be wrath and indignation,
9 tribulation and anguish, upon every soul of man that worketh evil, of the Jew first, and also of the Greek;
The great point of Romans 2 is that it comes immediately before Romans 3. The whole point of Chapter 2 through to 3:20 is to point out that Jews are no better than Gentiles (Romans 2:12) and that both are guilty before God (Romans 3:19-20). Therefore, if anyone is to be saved, it will not be by works but by grace (Romans 3:21ff).
I have had a quick look at the occurrences of
dikaioo, 'justify' in the N.T. and I cannot find anywhere that it says specifically that God Himself justifies the righteous. On the contrary, He justifies the ungodly (Romans 4:5) and Christ died specifically for the ungodly (Romans 5:6; c.f. Mark 2:17) who were the very people He came for. Therefore, if anyone supposes that he is righteous in himself (
contra Romans 7:18), he has nothing to do with Jesus Christ.
So what about these Last Day judgement scenes like Matthew 25:31ff when it is works that justify or condemn those being judged? On that day, our works will justify us; they will declare us righteous in God's sight; they will be the evidence that God has justified us when we were still in our sins, given us new birth, a new heart and a new spirit, and written His righteous moral law upon out hearts.
In Exodus 23:7, God declares,
"I will not justify the wicked," and He does not. Christ on the cross has paid the penalty for our sins; He was made sin, the very epitome of sin, and God punished our sin in Him, that we might become the righteousness of God in Him. This is Luther's 'Great Exchange;' that there on the cross, all our sins were laid upon His sinless shoulders an His perfect righteousness and obedience were credited to us who believe (Romans 5:19).
This is absolutely vital. We can have nothing to do with the Roman Catholic conflation of justification with sanctification, nor with N.T. Wright's teachings which are only marginally better. But nor can we accept the antinomianism of those who suppose that having justified us by grace, God then leaves us to our own devices. No! Our God and Saviour Jesus Christ gave Himself for us that He might purify us from every lawless deed,
and purify for Himself His own special people, zealous for good works (Titus 2:14).