Police say detectives saw Kenneth Smith, of Valley Stream, pull his car into a driveway Sunday evening, followed by an alleged drug transaction with a 39-year-old man.
Smith drove away after the alleged deal and officers, having learned he was driving with a suspended registration, pulled him over.
Police say they found three bags of heroin in Smith's possession and arrested him.
His young daughter, who police say was in the back seat without a car seat, was picked up by a family member.
The other man involved in the alleged drug deal was also arrested. He was charged with selling Smith the drugs, among other offenses.
Smith was charged with criminal possession of a controlled substance, endangering the welfare of a child and several vehicle and traffic violations.
He was expected to be arraigned later Monday. It wasn't clear if he had an attorney.