Henry Marin, 27, was sentenced after pleading no contest in the case. A conspiracy count was also dismissed.
Prosecutors say a woman who was cooperating with a sheriff's investigation handed Marin a burrito containing heroin. The exchange took place outside an Airport Courthouse courtroom were Marin was assigned. Investigators stopped the deputy before he went back into the courtroom.
Marin resigned from the sheriff's department in April.
The Associated Press contributed to this report.