They go to the prison which corresponds to the sex on their legal ID. Special consideration may be made for post-op transgendered people. Depends on jurisdiction. A MTF pre-op would be put in a male prison because the prison system doesn't want to risk sexual assault at a female facility. If he (she) was post op, probably has a chance to go to a female facility.