A person is obligated to show great care for orphans and widows because their spirits are very low and their feelings are depressed. This applies even if they are wealthy. We are commanded to [show this attention] even to a king's widow and his orphans as [implied by Exodus 22:21]: "Do not mistreat any widow or orphan."
How should one deal with them? One should only speak to them gently and treat them only with honor. One should not cause pain to their persons with [overbearing] work or aggravate their feelings with harsh words and [one should] show more consideration for their financial interests than for one's own. Anyone who vexes or angers them, hurts their feelings, oppresses them, or causes them financial loss transgresses this prohibition. Surely this applies if one beats them or curses them.
Even though [a person who violates] this prohibition is not [liable for] lashes, the retribution one suffers for its [violation] is explicitly stated in the Torah (ibid. 22:23): "I will display My anger and slay you with the sword." There is a covenant between them and He who spoke and created the world that whenever they cry out because they have been wronged, they will be answered as [ibid.:22] states: "When they cry out to Me, I will surely hear their cry."
When does the above apply? When one causes them suffering for one's own purposes. However, it is permitted for a teacher to cause them suffering while teaching them Torah, or a craft, or in order to train them in proper behavior. Nevertheless, he should not treat them in the same manner as he treats others, but rather make a distinction with regard to them and treat them with gentility, great mercy, and honor for [Proverbs 22:22] states: "For God will take up their cause."
This applies to both those orphaned from their father and those orphaned from their mother. Until when are they considered orphans in the context [of this mitzvah]? Until they no longer need a mature individual to support, instruct, and care for them and are able to see to all their own needs by themselves, like other adults.