WITH THE sentencing of John Poindexter to six months in prison, a major step has been taken to resolve the Iran-contra affair. A jury had previously convicted President Reagan's national security adviser on all five felony counts lodged against him, including conspiracy and obstructing and lying to Congress. It fell to U.S. District Judge Harold Greene to determine his sentence. The judge made the retired Navy rear admiral, the highest-ranking official to be brought to trial in this case, the only one of the seven defendants to be sent to prison. As painful as it is to contemplate the humiliation of an otherwise distinguished career officer, the decision was necessary and right.

In handing down the sentence, Judge Greene threaded his way unerringly and instructively through the maze that envelops the conduct of secret operations in a democratic society. The government must maintain some secrets, he said, but ''if members of the security apparatus could, with impunity, keep from those elected by the people that which they're entitled to know -- or worse, feed them false information -- those who control the classified data could be the real decision makers. That is precisely what happened here.'' The Iran-contra defendants, he said, notwithstanding their military distinction, ''have no standing in a democratic society to invalidate the decisions made by elected officials.''

As to why it was appropriate to sentence only this single defendant of the seven to prison, Judge Greene described Adm. Poindexter -- who had insisted that he never informed his chief of the decision to divert profits from secret U.S.-Iranian arms sales to get around a congressional ban on supporting the Nicaraguan contras -- as ''the decision-making head'' of a scheme to deceive Congress and to ''invalidate the decisions made by elected officials.'' In short, the prison term establishes the accountability of the man who said, ''The buck stops here with me.''

The accusation that a court is ''criminalizing political decisions'' is again being heard. Judge Greene's words nail it. Adm. Poindexter is not being sentenced for conduct of a controversial policy but for violating the essential condition of democratic government, a condition doubly important in a context of secret operations: one branch's trust in the other's word. A prison term, even a term measured in months, is a severe sentence -- and one that is in keeping with the gravity of the offense.