A 55-year old former convict who attracted national publicity when he ran an unsuccessful campaign for Fairfax County sheriff in 1975 was sentenced yesterday to spend 20 years in prison for sodomy.

Fairfax Circuit Court Judge Thomas Middleton sentenced Charles B. Lankford following his conviction Dec. 19 on three charges of sodomizing a teenage girl.

The jury had recommended a 30-year sentence, but Middleton reduced it, in part, he said, because of the defendant's age and the probability that he will have difficulty getting paroled in view of his prior record.

Released from prison in the late 1960s after serving 20 years for armed rebbery and a parole violation, Lankford did volunteer rehabilitation work with ex-offenders. His citizenship was restored by then Virginia Gov. Linwood Holton in 1972 because of his work with former prisoners.

Yesterday, trembling nervously, the gray-haired Lankford referred to those works in making a last-minute plea for leniency.

"I have worked hard for 10 years trying to be the kind of person people respect," he said.

"Mr. Lankford, that is one of the things that has concerned me through this case, [but] the jury had the final say and they made the final decision," Middleton responded. Middleton said the charge against Lankford constituted what he called "a very serious form of child abuse."

Shortly before his arrest last summer, Lankford, who had run unsuccessfully in 1975 against County Sheriff James D. Swinson, was given a job by Swinson as cook in the county jail at an annual salary of $11,500.