The length of time required for heroin detox in a residential rehab setting can vary depending on several factors, including the individual's medical history, the severity and duration of the addiction, and whether other substances are also being abused.