A former Department of Health Education and Welfare information specialist was sentenced yesterday to two years in prison for his guilty plea to a fraud charge growing out of a probe of financial irregularities within the FBI.

U.S. District Court Judge Charles R. Richey said he was imposing the prison term on Marvin A. Beers, 66, solely in an attempt to deter other white-collar criminals.

In imposing the prison term, Richey rejected a suggestion by Beers' attorney that the defendant be allowed to do community-based service work.In addition, federal prosecutor John Dowd told the judge that Beers had been fully cooperating with proseuctors in their continuing investigation.

"In this kind of case there must be an element of deterrence of others," Richey said in imposing the sentence. Beers, who can be paroled at any time by the U.S. Parole Commission, was given a few days to set his affairs in order before reporting to prison.

Beers pleaded guilty to charges of conspiring to defraud the federal government of more than $30,000 over a 19-year period by issuing fake invoices to cover work allegedly done by the U.S. Recording Co., a Washington electronics firm.

Although the indictment covered a period from 1953 to 1972 in making that estimate, it specifically charged Beers with illegally obtaining $10,000 in 1972.

The activities of the U.S. Recording Co. have been under investigation since allegations on Capitol Hill that the firm had been favored by the FBI in its awarding of contracts for the secret purchase of thousands of dollars worth of electronic surveillance equipment.

The firm's president, Joseph Tait, also has been indicted as a result of the investigation. Tait is a longtime friend of John P. Mohr, formerly the No. 3 man at the FBI.