Would a man still be committing the "sin of Onan" if his wife is beyond child-bearing age?
Onanism, i.e., a husband’s spilling his seed outside of his wife’s womb, is never morally permissible (see Gen. 38:1-10). God has inscribed an unbreakable bond between the love-giving and life-giving aspects of the marital act, which endures even if a wife is beyond child-bearing years. Otherwise, the marital act would be prohibited altogether after child-bearing years, illustrating that the life-giving aspect is not restricted to the procreative fruit of children but also extends to the mutual building up of husband and wife.
God designed the marital act for husband and wife to become one and to renew that covenant in conjugal relations throughout their married lives. Indeed, God designed marriage to be a free, total, faithful, and fruitful covenant between a husband and wife; and conjugal love, as the quintessentially marital act, is to reflect that whole and unreserved commitment between the spouses. Onanism is certainly not a total giving of husband to his wife, nor a faithful one, irrespective of whether procreation is possible. And an onanistic husband also deprives his wife of the non-procreative beneficial effects his seed provides her.
For more on onanism, please see this article from our magazine.