Three years ago, the commodity buyers for Frito-Lay Inc., the Dallas-based food company, looked like geniuses.

With the help of a small-town Georgia peanut broker, Frito-Lay snapped up the government's stock of surplus peanut oil at bargain prices. Then it watched the price double in the weeks that followed as Arthur Treacher's and other competitors in the fast-fried-food world fought over the remaining privately held supplies.

Now, a federal grand jury in Dallas wants to know whether officials of Frito-Lay, its parent company, PepsiCo Inc., the Agriculture Department and others were involved in a conspiracy to corner the peanut oil market illegally.

James H. Stafford, Frito-Lay's chief commodities buyer until the company fired him in 1978 for misconduct, admitted in a Dallas federal court Thursday that he had been involved in such a scheme. While pleading guilty to conspiracy charges, Stafford agreed to cooperate with the grand jury's investigation of the Frito-Lay peanut oil purchase, in hopes of a lighter sentence.

Frito-Lay, denying any wrongdoing says it is "outraged at the invented accusations" against the company made by Stafford. Company spokesman Joe McCann said Frito-Lay had given the Justice Department evidence of "very suspicious behavior" by Stafford two years ago and has cooperated fully with the inquiry.

The investigation is focused on the Agriculture Department's sale of nearly all its peanut oil stocks on Nov. 2, 1977. Although the sale had been advertised in advance, there were only a handful of would-be buyers. One was the Camilla Cotton Oil Co., of Camilla, Ga., which purchased most of the oil, 78 million pounds, for $15.7 million, or 20.25 cents a pound.

Camilla immediately resold the oil to Frito-Lay for 21.5 cents a pound. It was still a bargain. The market price for peanut oil on the day of sale was 23.5 cents per pound and it soared to nearly 43 cents in early January.

Following the sale, Frito-Lay's outraged competitors charged that they had not bid because they had no idea the Agriculture Department would sell such a large block to a single purchaser. Prior to the Camilla sale, the department had generally offered smaller quantities for sale.

Among the questions said to be under investigation by the grand jury are whether Camilla received favorable treatment from Agriculture Department officials, what was the understanding between Camilla and Frito-Lay about the sale, and did outsiders attempt to use political influence to persuade the Agriculture Department to sell off its peanut oil stocks.

Frito-Lay says it was victimized by its former employe, Stafford, who directed the peanut oil purchase as head of the company's commodities office. McCann said the company's internal investigation disclosed that Stafford had secretly invested in a West Texas company that was Frito-Lay's largest corn supplier. Frito-Lay sued Stafford and others, recovering $13 million from them, according to court records. Although this controversy isn't related to the peanut oil purchase, Frito-Lay cites it in defense against Stafford's charges.

Frito-Lay was Camilla's secret partner in the peanut transaction, according to a 1978 Agriculture Department audit of the sale. Although Frito-Lay advanced funds to permit Camilla to make the purchase, the role of the Dallas company was concealed from the Agriculture Department at the time of the sale, according to department officials.

A short time after the sale, Camilla purchased 2.4 million pounds of the oil back from Frito-Lay for 21.5 cents per pound, a transaction that represented a potential profit of more than $500,000 for Camilla if the Georgia company sold the peanut oil when the price hit 43 cents a pound.

Although several members of the Senate Agriculture Committee urged the Agriculture Department in 1977 to sell the surplus peanut oil stocks, the department audit does not allege that any senator was involved in the Camilla transaction in any way.