For St. Thomas, every moral precept -- which binds under pain of mortal sin -- "is reducible to the precepts of the Decalogue." If almsgiving is, under certain circumstances, a matter of precept, it must be found in one of the Ten Commandments.
Chris Sullivan has commented several times that breaking this precept breaks the Seventh Commandment, "Thou shalt not steal." That makes sense, given the choice of Commandments, and particularly in light of the Patristic tradition that the rich man's extra clothing belongs to the poor. The Catechism, too, discusses almsgiving in its section on this Commandment.
It's curious, then, that St. Thomas teaches that the precept of almsgiving is based on the Fourth Commandment:
All succor given to our neighbor is reduced to the precept about honoring our parents. For thus does the Apostle interpret it (1 Tim. 4:8) where he says: "Dutifulness [Vulgate: 'Pietas'; Douay: 'Godliness'] is profitable to all things, having promise of the life that now is, and of that which is to come," and he says this because the precept about honoring our parents contains the promise, "that thou mayest be longlived upon the land" (Ex. 20:12): and dutifulness comprises all kinds of almsgiving.
Well. This wants rumination. But to see what St. Thomas is getting at, you need to see what he means by "piety" or dutifulness, in particular why piety requires us to support our parents in their need:
Accidentally, that is due to a father, which it befits him to receive in respect of something accidental to him, for instance, if he be ill, it is fitting that his children should visit him and see to his cure; if he be poor, it is fitting that they should support him; and so on in like instance, all of which come under the head of service due.
So our parents are "accidentally" due our support should they accidentally need it (though "it is essentially fitting for a father to support his son").
It seems to me, as I type this, that St. Thomas left a lot unpacked in the flat assertion that "dutifulness comprises all kinds of almsgiving" ("sub pietate autem comprehenditur omnis eleemosynarum largitio"). However, choosing the Fourth Commandment rather than the Seventh does seem to have a couple of advantages. First, it affords a gentler transition from precept to counsel; it's a longer stretch, I'd say, to see the widow's mite as having been stolen from someone else than as a form of honor due the poor. Second, it better encompasses all forms of alms; not just money and material goods, but spiritual alms as well. Would we say, except by distant analogy, that we "steal" prayers from the poor?