Heroin increases the amount of dopamine in the reward pathway by boosting the activation of synapses, causing euphoria.
Because of this the brain reduces its natural levels of dopamine
this means that when the drug leaves the system, the person is left with lower levels of dopamine than they would have had
This causes dysphoria which motivates the person to take more heroin to stop feeling bad.
Further repetition of using the drug leads to further depletion (down-regulating) of the dopamine stores which makes the individual rely on the drug to avoid withdrawal symptoms.