At the end of Side Effects (2013), Dr. Banks says that Emily still needs medication, but to me, as audience, she looked fine, she commit all truth. Why is she forced to take the medication?
She doesn't. Dr Banks said that/prescribed the medications as some sort of payback for what she did. So despite of her cooperating with the police (which she did to save herself), he simply still think she shouldn't get away free.
As retaliation for Emily's part in the plot, Jonathan, who still technically oversees her case, prescribes Thorazine and Depakote and describes the drugged stupor they will cause to....
Emily goes to see Banks. Banks exacts his revenge, saying she is only released on the condition she follows his orders. He begins prescribing medication that will essentially make her a lifeless zombie....
Ref - Side Effects Explained
The US procedural defence states that a defendant cannot be tried again on similar charges following a legitimate acquittal or conviction. Since Emily was acquitted once already on the charge of Martin’s murder she can’t be tried again. Johnathan comes up with an alternate plan. He prescribes some drugs with some insane side effects to Emily. She throws a fit and Johnathan declares that Emily is no longer fit to be under his care and that she’s taken back to mental ward for refusing treatment. Over some time there based on her treatment, Emily eventually becomes zoned out and loses her mind because of all the medication.
Johnathan gets his revenge on both Victoria and Emily and gets his life back.
Emily would have walked free because of that loop hole mentioned in the law, in spite of committing murder. Johnathan wants to ensure she doesn't go unpunished. He plots to have her under the medication in the mental ward. That is her punishment.
I haven't seen the movie, but your statement seems at odds with Wikipedia's description:
As retaliation for Emily's part in the plot, Jonathan, who still technically oversees her case, prescribes Thorazine and Depakote and describes the drugged stupor they will cause to Emily; when she balks, he says he will recommend sending her back to the ward if she refuses to take them, per the terms of the agreement she signed. Furious, Emily rants about all that she has done to avoid being sent to prison for Martin's death. Unbeknownst to her, Martin's mother, her lawyer, and a police officer are all outside the room and hear the confession. The police take Emily into custody and send her back to the mental ward for refusing treatment.
In the final scene, Jonathan has regained his normal life with his wife and stepson. Emily, now a patient at a mental hospital, stands and stares blankly through a barred window. A psychiatric nurse asks Emily how she's feeling, and she responds by saying: "Better. Much better."
She didn't know her confession was witnessed by others, and thus her schemes were uncovered.