David Brack (37) had been approved for the community work by the probation service but the judge said she was concerned that while he was now stable on methadone, he tested positive for other drugs.
Judge Bridget Reilly said Brack had had cannabis and another drug in his system when he was approved to carry out 80 hours' community service instead of a two-month jail sentence.
She referred his case back to the judge who had originally asked for the report on the accused.
Dun Laoghaire District Court heard Brack had the heroin to supply to friends when it was found at his home. He had turned back to the drug after his dad's death and gardai found heroin in his home when they raided it with a search warrant.
The accused, with an address at Davitt Park, Ballybrack, pleaded guilty to possession of heroin with intent to sell or supply at his home on February 2 last.
"This is a situation where, if sale or supply was involved, it was amongst friends. It's not as if he was standing on street corners selling it to children," his solicitor Ronnie Lynam said.