"The Tunisian government should not be prosecuting people for private and consensual sexual acts," said HRW's deputy Middle East and North Africa director Eric Goldstein.
"If Tunisia truly aspires to be a regional leader on human rights, it should lead the way in decriminalising homosexual conduct."
The youth had been detained on September 6 in the Mediterranean resort area of Sousse for questioning in connection with a murder after his telephone number was found on the victim, lawyer Fadoua Braham said.
Signup to our newsletter and follow us on Facebook and Twitter!
He denied any involvement in the murder but admitted to having had sexual relations with the victim.
"Another statement was drawn up and my client had to undergo an anal exam against his will," she said.
HRW condemned the use of forensic anal examinations of people suspected of homosexual acts and called on Tunisia to halt them immediately.
"Such examinations are intrusive, invasive, and amount to cruel, inhuman, and degrading treatment that violates international law," it said.