The actor, who plays Sayid on the hit US series, said he lost two years of his life to the drug before checking into rehab in a bid to get clean.
In an interview on Friday Night with Jonathan Ross, he said: "There was a danger of me copping it. I lost two years to heroin, but I was able to work, I don’t know how I did it.
"You can take incredible abuse and still work... I collapsed on a job because of booze. When I was younger... it was a miracle I got any work done. On The English Patient I was warned. But I used to collapse out of shot."
He added that he had finally kicked the habit because of his son, saying: "The turning point was I drove my son when I was drunk and he was scared, and that’s when I decided to go into rehab in LA."
The 39-year-old said he has no plans to leave the show, although he admitted that the quality of the scripts had deteriorated after the first two series.
He told Ross: "I’m still proud of the first season, around the third I thought they were winging it, the writing was poor but I’m definitely doing two more years.”
Friday Night With Jonathan Ross airs tonight on BBC One at 10.35pm.