The owner of a small Virginia restaurant who was charged with refusing to serve blacks was sentenced yesterday to 30 days in jail and told he can serve the time on a work-release program.

U.S. District Judge James C. Cacheris imposed the sentence on 61-year-old Roy E. McKoy 17 years after another federal judge directed him to serve blacks at his Belvoir Restaurant near Marshall, Va., about 50 miles west of Washington.

McKoy pleaded guilty in federal court in Alexandria last month to refusing to serve a black customer in violation of the court order, the third time he had admitted in court to refusing to serve blacks. He had faced a maximum penalty of six months in jail and a ,000 fine.

Cacheris told McKoy that since this was his "third violation of the court's injunction . . . some incarceration is necessary in order to have respect for the rule of law and deterrence."

A Prince William County civil rights activist who was refused service at the restaurant in October, said, however, she was disappointed by the sentence. "As far as I'm concerned I think it was just another slap on the hand," Lori Jackson said in an interview. "It remains to be seen whether or not Mr. McKoy intends to comply with the law."

"What's this country going to be next?" McKoy said. He said his sentence was "slavery . . . in those foreign countries, this is the way they punish."

McKoy, who once said that he did not believe that constitutional protections apply "to dark people," was first jailed in 1967 for refusing to comply with the court order, and in 1974 he was found in civil contempt of that injunction.

Last December the Justice Department charged McKoy and his wife Patricia, 49, with civil and criminal contempt of the 1967 and 1974 court orders after several incidents in which the McKoys allegedly refused to serve individuals because of their race.

On Feb. 8 McKoy pleaded guilty to one misdemeanor count of refusing to serve a chauffeur, Alvin C. Talley, in September 1983. In return, the government dropped six other criminal charges against McKoy and one against his wife, who waits on tables at their roadside restaurant, off Rte. 55.

The couple also agreed on Feb. 8 to meet certain demands of the government to settle the civil contempt charges. They agreed to post a sign saying they would serve people of all races and colors; to report monthly to the U.S. attorney's office in Alexandria the number and race of the people they had served; to purchase "corrective" advertising in an area newspaper saying their establishment serves all customers and to post $500 as surety for complying with the decree.

McKoy's lawyer, Thomas O'Neill, told Cacheris yesterday that the McKoys had been through "a tremendous ordeal" and that their business had suffered because of "this veritable siege they were under by the press." He said that the McKoys did serve blacks in their restaurant; that the refusal to serve Talley had been "an isolated instance" and that other charges of discrimination against McKoy had been "media generated."

The McKoys have also been sued by Jackson in a civil case charging them with violating her civil rights by refusing to serve her at their restaurant. A date for trial of that case has not been set.

Cacheris ordered McKoy to report for his sentence March 15. It will be served at a local jail, O'Neill said.