It depends on the substance and the severity of your addiction. For some addicts, complete removal from familiar environments and temptation is necessary to break the cycle of drug abuse. Others may do well with outpatient treatment or therapy.
Be honest about the severity of your addiction with your medical provider so they can formulate the most successful treatment plan for you.