Greece's Socialist government, in a bid to consolidate the presence of loyalists in key military command posts, initiated a sudden shake-up of large numbers of senior officers last week.

The changes, which led to the appointment of new chiefs of the general staff, the Army, the Navy and the Air Force, coincided with a government announcement at the beginning of the week of a decision to adopt a "new defense dogma" in January 1985.

This will reflect the Socialists' conviction that the main military threat to Greece comes from Turkey to the east rather than the Warsaw Pact to the north.

The sweep also comes three weeks after reports of a right-wing conspiracy by retired and active Army officers, following a number of unexplained bombings in Athens. Prime Minister Andreas Papandreou hinted strongly at the time that these rumors were true while the Defense Ministry was placed on alert for two days, ostensibly for a "flood emergency."

According to sources close to the Army, the changes have generated "turmoil" among the ranks, particularly since the Greek promotion system requires an officer who has been retired to quit his post virtually overnight. "At its best, it's like a purge," one source said.

In addition, the higher echelons of the military were caught by surprise by the sweeping retirements and promotions, which are an annual event but which this year were unusually extensive and came unusually early.

At least three senior Army commanders, according to reliable sources, heard of their unexpected retirement on state television. The new Army lists routinely are announced in February or March.

These developments have served to intensify the speculation that routinely surrounds the annual changes in the Army hierarchy in a country that was ruled by a military junta from 1967 to 1974.

Defense analysts say more time is needed to study the changes before reaching final conclusions on their nature and purpose. But some are already tentatively linking the military shake-up with the government's new defense doctrine. The ruling Panhellenic Socialist Movement has denied any link either with the new defense policy or the rumored military plot last month.

The analysts say that the changes have removed from active duty military men who tended to be closer to the NATO philosophy of a prevailing threat from the Communist Bloc. Some of them were veterans of the Korean conflict and the Greek civil war of 1945 to 1949 that led to the crushing of the local Communist forces.

Their places, according to the analysts, have been taken by officers distinguished by their loyalty and close connection to the government. They are judged more likely to be receptive to gearing national defense to Socialist concepts of a predominant Turkish threat from the east.

"There is no question that the government is promoting able men. But in two to three years' time almost no officer will have fought in the civil war," one military expert said.

"It's also not to say that the officers who left did not see Turkey as a real threat," he said. "Almost any Greek officer would. But they were not fanatical; they were subject to rational discussion about it."

The highlights of the military changes include the appointment of Air Vice Marshal Nikos Kouris, a known government loyalist, as chief of the General Defense Staff, and Lt. Gen. Dimitris Apostolakis, who was jailed for taking part in a 1973 Navy uprising against the junta, as chief of the Air Force.

There was considerable surprise at the retirement as chief of the Army of Lt. Gen. Vassilis Kourkafas after only nine months. He was replaced by Lt. Gen. Epaminondas Pentheroudakis, whose career includes a post as defense attache in Bulgaria.

Under the Greek promotion system, the new appointments led to the retirement of six lieutenant generals, 12 major generals, 20 brigadiers and two rear admirals. Under the Greek system, the promotion of an officer of a younger class automatically means the retirement of his seniors.

The government rejected opposition charges that it was trying to "politicize" the armed forces and countered by saying that it was trying to unclog lower ranks that had stagnated due to a lack of promotions under previous administrations.

The changes represent an effort "to fulfill promises to form a disciplined and combat-worthy Army, in the full knowledge of the role of the armed forces and the critical circumstances facing the country," a government spokesman said.