They are written at the end of the verb. For example, “I studied it” (if “it” is masculine) is درستهُ . If “it” is feminine, then you have درستها . “I saw them (masc) is شاهدتهم. However, you should note the following points.
1. When a verb is conjugated for هم , it ends, as you know, in وا. For example درسوا “they studied.” The alif at the end is just a spelling convention. When we attach a direct object pronoun to this ending the alif is dropped. For example درسوهُ”They studied it.”
2. When a verb is conjugated for أنتم we add تُم as a suffix. For example درستُم Whenever a direct object pronoun is attached to this suffix we place a و between the verb conjugation and the pronoun. So to write, for example, “You (masc. plural) studied it,” we write درستموهُ.
3. All the possessive pronoun suffixes and direct object pronoun suffixes are the same except one. The one that is different is for the first person singular. The possessive pronoun suffix for the first person singular is ي but the direct object pronoun for it is ني. Thus “He saw me” is شاهدني