Convicted paedophiles could also be forced to wear electronic monitoring devices following their release from jail under new rules introduced in an emergency decree.
"This regulation is intended to overcome the crisis caused by sexual violence against children," President Joko Widodo said late today at the presidential palace in Jakarta.
"Sexual crimes against children are extraordinary crimes, because they threaten the lives of children."
The presidential decree brings the new punishments immediately into effect, although parliament could later overturn it.
More From This Section
Her battered body was found three days later in woods, tied up and naked. Seven teenagers, aged 16 and 17, were jailed earlier this month over the assault.
The attack sparked a national debate on sexual violence, led to calls for harsher punishments for child sex offenders and prompted protests in the capital Jakarta.
The case has drawn comparisons with the fatal gang-rape of a student on a bus in Delhi in 2012, which sparked mass protests and led to an overhaul of India's rape laws.
Under previous laws, the maximum sentence for rape -- including of a minor -- was 14 years in jail.
By introducing chemical castration, Indonesia joins a small group who use the punishment worldwide, including Poland and some states in the US. In 2011, South Korea became the first Asian country to legalise the punishment.