Argentina's ruling military junta announced yesterday that it is removing the relatively moderate President Roberto Viola and said Army commander Leopoldo F. Galtieri, a relative hard-liner, will replace him Dec. 22.

Under Viola, a retired general, the economy was thrown into the country's deepest recession of the century, a crisis his government was unable to stem. Interest rates and inflation topped the three-digit mark and at one stage the value of the peso fell from 2,000 to the dollar to 13,000.

Viola was also criticized by his colleagues for talking to the country's officially suspended political parties.

Removal of the ailing Viola, 57, came after the three commanders of the armed forces, comprising the junta, summoned him and formally requested his resignation for "reasons of health." Military sources said Viola balked at the demand, returned to his home and sent a reply that the junta rejected. His removal was foreseen and he had said it would be for political, not health, reasons.

The junta's public information secretary also reported the resignations of the interior minister, Gen. Horacio Tomas Liendo, who was acting president since Viola's mild heart attack Nov. 21; Foreign Minister Oscar Camilion, and the public works secretary, Gen. Diego Urricariet.

Gen. Galtieri, 55, was already the undisputed strongman as commander of the Army. He is to retain that post and serve out Viola's term, which was to run to March 29, 1984. Viola had given up the commander post before assuming office last March. He served at the behest of the junta, which is dominated by the commander of the Army.

The military seized power in a 1976 coup, toppling the civilian government of Maria Estela Peron.

Some political observers said the choice of Galtieri signaled the junta's wish for a strongman to counter increasing demands for a return to civilian government prompted by the country's worsening economic slump. He was recently quoted as saying, "Ballot boxes are safe under lock and key."

Social Welfare Minister Carlos LaCoste, a rear admiral, will act as interim president until Dec. 22.