To be "reckoned according to debt" ("credited as an obligation" in your transl.), "λογίζεται κατά το οφείλημα", is to be rewarded in justice, as when an employer pays his employee for the work he's done.
To be "reckoned according to grace" ("credited as a gift" in your transl.), "λογίζεται κατά χάριν", is to be rewarded freely, as when one gives a gift to someone. Χάρις (charis, "grace") means a freely given gift.
328. Then, when he says, now to him who works, he explains the aforementioned biblical citation as regards the words it was reputed to him as justice.
Two explanations of these words are given in the Gloss. In the first explanation they are linked to the final reward, concerning which
first, he shows how it is related to works;
second, how it is related to faith, at but to him who works not.
329. First, therefore, he says that to him who works the works of justice, the reward of eternal recompense—concerning which it is said, behold his reward is with him (Isa 40:10)—is not reckoned as a gift only, but according to debt: did you not agree with me for a denarius? (Matt 20:13).
But on the contrary it is stated below: the grace of God is life everlasting (Rom 6:23), and again: the sufferings of this time are not worthy to be compared with the glory to come (Rom 8:18). Therefore, that reward is not made as due, but as a gift.
The answer is that human works can be considered in two ways. In one way, according to the substance of the works, and considered this way they do not have anything deserving that the reward of eternal glory should be given.
In another way, they can be considered according to their source, namely, insofar as they are performed under God’s impulse in accord with the intention of God who predestines. And in this respect the aforesaid reward is due them by debt, because, as is stated below: for whosoever are led by the Spirit of God, they are the sons of God . . . and if sons, heirs also (Rom 8:14, 17).
330. Then when he says but to him, he shows how the eternal reward is related to faith, saying, but to him who works not outward works, for example, because he does not have time to work, as in the case of one who dies immediately after baptism, yet believes in him who justifies the ungodly, namely, in God, of whom he says below: God is he who justifies (Rom 8:33), his faith is reputed, i.e., faith alone without outward works, to justice, so that in virtue of it he is called just and receives the reward of justice, just as if he had done the works of justice, as he says below: with the heart, we believe unto justice (Rom 10:10), and this according to the purpose of the grace of God, i.e., accordingly as God proposes to save men gratuitously: to such as, according to his purpose, are called to be saints (Rom 8:28); he accomplishes all things according to the counsel of his will (Eph 1:11).
331. Another explanation refers those words to man’s justification.
He says therefore, to him who works, i.e., if anyone be justified by works, the justice would be reckoned as a reward, not according to grace, but according to debt: and if by grace, it is not now by works; otherwise grace is no more grace (Rom 11:6). But to him who works not, so as to be justified by his works, yet believes in him who justifies the ungodly, his faith is reputed to justice, according to the purpose of the grace of God, not that he merits justice through faith, but because the believing itself is the first act of the justice God works in him. For from the fact that he believes in God justifying, he submits himself to his justification and thus receives its effect.
This is the literal explanation and accords with the intention of the Apostle, who lays special stress on the words, it was reputed to him as justice (Gen 15:6), a saying which is used when that which is lacking on someone’s part is reckoned to him gratis, as if he had accomplished the whole.
That is why the Apostle says that such reckoning would have no place, if justice were from works, but only as it is from faith.