So there are transitive and intransitive verbs. Transitive verbs are verbs that take a direct object, like here पीना = to drink. It's a transitive verb because you have to drink something, there needs to be an object. In Hindi, verbs in past tense change depending on whether it's transitive or intransitive, if it's transitive like पीना, the conjugation goes off the gender of the object, चाय is feminine, so पी. Then intransitive verbs go off of the subject, which is I think what you were thinking of here. "I drank tea" = मैंने चाय पी. "I drank milk" = मैंने दूध पिया. "He went" = वह गया. "She went" = वह गई. (To go is intransitive as you can't "go something", you just go.)
Transitive verbs like पीना agree in number and gender with their object(s) rather than the subject in certain tenses (simple past, perfective tenses etc), as Zerenei has explained above.
When this happens, we need to modify the subject a little to indicate that the verb is not conjugating with it. In the case of nouns, this is done by having a ने follow the noun (eg: नेहा ने चाय पी).
In the case of most pronouns, it is done by tacking on a ने to the pronoun (eg: मैंने चाय पी). For the pronouns यह and वह, it is done by adding a ने to their oblique forms (Eg: इसने चाय नहीं पी). The pronouns ये and वे become इन्होंने and उन्होंने respectively (Eg: इन्होंने चाय नहीं पी).
Note: These forms of the pronouns are sometimes called the 'ergative case' forms because they identify the pronoun as being the subject of a transitive verb. However, as I mentioned earlier, they are used only in certain tenses and in the rest of the tenses, even transitive verbs conjugate with the subject as usual so these special forms are unnecessary. Therefore, there is some debate about this terminology.