Keeping the military out of politics is an axiom of American democracy so fundamental that a challenge direct from a Man on Horseback would surely be resisted. But a squalid affair last week shows that a far more insidious danger to the principle comes from a mix of bureaucracy-as-usual and right-wing jockeying inside the Republican Party.

The squalid little affair centers around Gen. David Jones is the very model of the modern military man. He packs no pistols, but is highly skilled in the managing of big budgets and large staffs. He played a central role in nudging this country toward a renewed emphasis on defense. Thanks largely to his efforts, the new funds are going for immediate readiness, not the glamorous weapons systems that can only pay off in the distant future.

Those qualities have earned Gen. Jones the admiration and respect of Defense Secretary Harold Brown. At Secretary Brown's behest, President Carter named Jones, an Air Force general, to be chairman of the chief's back in 1978 when the usual rotation favored an admiral. Two weeks ago, the president nominated Jones for a second two-year term as chairman.

Gung-ho military men in the Pentagon, and their more assertive allies on the Senate Armed Services Committee, disparaged Jones as a "military bureaucrat." They claim he has been a "patsy" for the Carter administration in lining up the chiefs behind the president on such matters as the Panama Canal treaty, the arms control treaty with Russia and the termination of the B1 bomber program. They blame his caution for the failure of the Iranian mission.

When the reappointment was announced, a group of the discontented from both political parties talked quietly of using the confirmation hearings as an occasion for a massive assult on a whole range of administration actions in the field of national security. Jesse Helms, the conservative Republican from North Carolina, went into vocal opposition. He spoke of a filibuster that would delay the appointment so that if Ronald Reagan was elected, the new president would have a chance to name his own man as head of the chiefs.

At that juncture, two other Republican committee members entered the picture. On June 2, John Tower of Texas spoke with Jones about the confirmation hearings. The two men found accord in a provision of the law that asserts that the chairman, like all general officiers, serves at the "pleasure of the president." That implied to Sen. Tower that if Reagan were elected, Jones would step down as a good soldier.

On June 3, John Warner of Virginia, after discussion of the confirmation with Sen. Helms, telephoned Jones. He made reference to the earlier talks between Tower and Jones. He and Jones also agreed that the law provided that the chairman served "at the pleasure of the president." Warner drew from their talks the conclusion that, if he proved unsatisfactory to Reagan, Jones would "step aside."

Helms was informed of Warner's discussion, and immediately moved to claim his scalp. He announced that "Jones has agreed to tender his resignation in January if Gov. Reagan is elected." The Senator said that in those circumstances, he would not make a "ruckus" in the confirmation hearings.

Jones then came roaring back. He issued a written statement denying that he had offered to resign. He said: "The integrity of the chairman's office is an overriding consideration, and I consider it totally inappropriate for senior military officiers to adapt the tradition of political appointees of offering resignation whenever an administration changes."

Secretary Brown has backed up the chairman, and a couple of senators have also spoken up for Jones. He probably will be confirmed swiftly.

But that is not the point. The point is that the chief's are professional military officiers. They have an obligation to obey the presidents as commander-in-chief, and also to offer, when it is sought their best advice for Congress.

Balancing those sets of loyalties is not always easy or automatic. It depends on qualities of sensitivity and restraint. Judged by those standards, nobody in this affair comes off very well.

Helms and other senators who lack the courage to come forward were actually trying to punish Jones for not defying the president. Tower and Warner, perhaps innocently, lent themselves to a politicization of Jones' office. Jones protested -- but only lat in the game. His colleagues among the other chiefs, though clearly involved, have not said a word publicly.

In other words, a great principle came close to being breached without anybody's much noticing. Such is the nature -- and the great danger -- of a bureaucratized military in a highly political atmosphere.