Sex offenders, most specifically those who rape, should not only have their testicles removed, but their penis too.
In this case, rape (in the conventional sense) can't be committed by the offender again. It also acts as a deterant to those who would commit it, as the punishment is permanent and well-fitting of the crime committed.
Castration, as put to in other arguments, can be got around, and with a penis still remaining, rape can be committed again. Without a penis, it cannot, not with the same devastating effects.