This particular passage, to me at least, seems to be talking about habitual sin. I believe the Church teaches that the culpability for habitual sin, such as masturbation, is or can be reduced based on the fact that it is habitual and therefore may not necessarily be completely willful (one of the factors for a mortal sin).
The Haydock Commentary says:
Ver. 15. For that which I work, I understand not. To know, or understand is often, in the style of the Scriptures, the same as to approve or love: so the sense here is: I approve not what I do, that is, what happens to me in my sensitive part, in my imagination, or in the members of my body, which indeed the just man rather suffers than does; and this is the sense, by what immediately follows, the evil which I hate, that I do, i.e. that I suffer, being against my will; and I do that which I would not. (Witham) — I do not that good which I will, &c. The apostle here describes the disorderly motions of passion and concupiscence; which oftentimes in us get the start of reason, and by means of which even good men suffer in the inferior appetite what their will abhors: and are much hindered in the accomplishment of the desires of their spirit and mind. But these evil motions, (though they are called the law of sin, because they come from original sin, and violently tempt and incline to sin) as long as the will does not consent to them, are not sins, because they are not voluntary. (Challoner)
Ver. 17-18. Now then it is no more I that do it: To will good is present with me. These expressions all shew that he speaks of temptations that affect the sense only, the imagination, or the members of the body, but to which the mind and the will give no consent, but retain an aversion to them; and so long they never can be truly and properly sins, which must be with full deliberation and consent. (Witham) — The apostle here means to say, that he knew by experience that evil and not good dwelt within him, according to the flesh. He does not contradict this passage when he says elsewhere, that our members are the temples of the Holy Ghost: (1 Corinthians iii. 6.[16.?] &c.) for good cannot be found in our flesh, inasmuch as it is corrupted by sin; whence our Saviour says, “What is born of flesh, is flesh.” (John iii.) But good is in our body, when our members under the influence of the soul, renewed by the Holy Ghost residing in it, are employed in good works. The meaning of this passage is, that although now healed and renewed by grace, he could have a perfect desire of doing good; yet still on account of the evil of concupiscence dwelling in his flesh, he found not himself able to perform all the good he wished, because concupiscence was always urging him on to evil against his will. (Estius)
Ver. 22. I am delighted with the law of God according to the inward man. As long as the inward man, or man’s interior, is right, all is right. — (I perceive another law in my members, fighting, and different from the law of my mind: this is true in any man just striving against and resisting temptations, but not of the sinner, whose mind also and will consent to them. A man can never lose God’s favour and grace, unless his mind and interior consent. — These hold me as it were captive in the law of sin, or sinful inclinations, but which are in the members only. I cry out, who shall deliver me from the body of this death, from this mortal body with its sinful lusts, which if consented to would bring death to the soul? Nothing but the grace of Jesus Christ can secure me from such temptations, and by freeing me from this body, can make me perfectly happy; which cannot be hoped for in this life. But I have still this greatest of consolations, that I myself, with my mind and will, still serve God, and remain firm in obedience to his laws; but with the flesh, or in the flesh, I am subject to the law of sin, i.e. of sinful inclinations. — We must avoid here two heretical errors; that of those late pretended reformers, who denying man’s free will, hold the commandments of God impossible, even to a just man. See also the first heretical proposition of Jansenius. Next we must detest the late abominable error of those called Quietists, who blushed not to say that a man might yield and abandon himself to the most shameful disorders of the flesh, pretending that it was not they themselves, but sin and the devil that caused these abominations in their flesh. St. Augustine foresaw this frivolous excuse: (lib. i. de. nup. and Concup. chap. xxviii.) “That man (saith he) is in a grievous mistake, who, consenting to the concupiscence of the flesh, and to do what the flesh prompts him to, thinks he can still say: It is not I that do that,” &c. (Witham)