A federal judge ordered a Haymarket, Va., gun dealer jailed for up to eight months yesterday for contempt of court after he refused to testify before a grand jury investigating an April 1980 marijuana smuggling case in Southside Virginia.

District Judge Albert V. Bryan Jr. ordered Kenneth O'Day held for the duration of the grand jury session in Alexandria -- until June 1982 -- after O'Day declined to furnish details about the case despite a grant of immunity from prosecution.

O'Day could be freed if he later agrees to testify.

Bryan rejected a request by defense attorney Gerald Lee that O'Day's imprisonment be delayed pending a hearing on an eavesdropping device O'Day said he found outside his home last month. O'Day said he believed the device had been planted by government agents.

Prosecutor Karen Tandy, calling O'Day's statement "a wild guess," told Bryan several federal law enforcement agencies had denied under oath they had engaged in electronic surveillance of O'Day's residence.

During the 30-minute contempt hearing, Lee said O'Day, a licensed weapons dealer, was unwilling "as a matter of conscience" to testify to the grand jury about an unnamed, older man to whom he regarded as a close friend and who is now deceased.

A source familiar with the investigation said later the man was William McKenley Dickerson of Leesburg. Dickerson, then 49, was arrested by federal agents on April 15 of last year in Clarksburg, Va., as he stood beside a small, twin-engine plane carrying 700 pounds of marijuana.

According to trial testimony, the plane had been tracked across several states by U.S. Customs agents using a transmitter attached to the plane by a Texas law enforcement officer.

Dickerson was sentenced in September 1980 to six months in prison by District Judge D. Dortch Warriner on a reduced charge of possession of marijuana with intent to distribute. Dickerson reportedly died while the conviction was on appeal.