Exxon Corp. overcharged customers $895 million for crude oil produced from a Texas oilfield between 1975 and 1981 and must pay the money back, a federal judge ruled yesterday.

Describing Exxon's actions as wrongdoing on a "colossal scale," U.S. District Judge Thomas Flannery ordered the nation's biggest oil company to pay the government nearly $1 billion in overcharges and interest. The federal government then will give the money to the states for energy conservation programs and to help poor people pay energy bills.

The refund is the largest ever in a series of cases brought by the Department of Energy against major oil companies for allegedly violating now-defunct oil price controls.

Exxon called yesterday's decision "incorrect and unfair" and said it will appeal the ruling, which it says attempts to apply regulations retroactively.

Jack Bennett, a senior vice president and director of the company, said that, if Exxon is required to make the repayment, it will turn around and ask the government to refund the federal income and windfall taxes paid on the excess income over the years. He could not estimate the amount of the refund the company would desire.

The repayment ordered by Judge Flannery of the U.S. District Court for the District of Columbia is greater than the DOE's $660 million fiscal 1983 budget for energy conservation efforts.

Exxon last year had profits of $4.2 billion on sales of $103.6 billion.

The company was charged with violating price-control regulations by selling "old" oil at higher "new-oil" prices. The government has estimated that such overcharges may have cost consumers a total of $10 billion in the past decade.

In his ruling, Judge Flannery wrote, "Exxon pushed the agency at every turn and probed each nuance in the regulations to interpret them to Exxon's advantage, sometimes ignoring their unequivocal dictates."

Flannery added, however, that it could not be determined that Exxon knowingly had attempted to circumvent price controls, and he declined to assess a $38 million civil penalty against the company as requested by the department. "DOE has not proven, because it need not, that Exxon in fact gerrymandered production . . . in an attempt knowingly to circumvent price controls," the judge wrote.

Flannery said that, because it would be impossible to apportion the overcharges among other oil companies and consumers who were victimized by the actions, Exxon must put the money into an escrow fund in the U.S. Treasury to be administered by the Energy Department.

Under a law passed late last year, the money then is to be given to states for use in financing programs mandated by DOE, including weatherizing buildings, promoting energy conservation by small businesses and individuals, implementing state energy conservation programs, finding cheaper energy sources for, or conserving energy used by, schools and hospitals, and helping the poor pay home utility bills.

"The broad scattering of the ill effects of Exxon's wrongdoing renders impossible the tracing of the overcharges to their ultimate victims and the calculation of the precise damages suffered by each," the judge wrote.

The case against Exxon has its roots in the price controls put on the oil industry in the wake of the 1973 Arab oil embargo. Under those regulations, oil prices were set at two levels. Prices of "old" oil--defined as the 1972 production level from a field--were set at a much lower level than those of "new" oil, which was any oil produced in excess of the 1972 rate.

Flannery ruled that Exxon misclassified the oil produced at the 40-year-old Hawkins Field, about 90 miles east of Dallas, so that, even though production there was dropping, more oil was sold at the higher price level. "Despite the steady decline in production, an increasing percentage of oil was accounted for by Exxon as upper-tier, higher-priced oil, until beginning June 1, 1979, almost all of the then 62,000 barrels per day was classified as new oil," the judge wrote.

Exxon claimed that it reclassified the oil as "new" oil because the company was using enhanced-recovery methods to squeeze oil out of the field and because the DOE had delayed clarification of how the use of those methods and other technicalities affected the classification of oil under the price-control rules.

The company also said that, although it is responsible for the repayment as the operator of the oilfield, it only owns about two-thirds of the 10,000-acre property and would expect the 2,300 individuals and companies who own the remainder to pay their share of the repayment, if the decision stands up to appeal.

In its statement yesterday, Exxon said Flannery "seems to be allowing a retroactive application of regulations that were not even announced by federal energy officials until almost two years after the investments by the Hawkins owners [in enhanced oil recovery] began."