Not long ago, Clarence D. (Doc) Long was asked about his tenure in the U.S. House of Representatives, about a career that has spanned six presidents and etched his name indelibly in the political lore of Capitol Hill.

"If I had to do it over again, I wouldn't," Long said matter-of-factly. "But I'm glad I did."

The comment seemed to suggest that Long's life on the Hill was ending, as it finally did on Tuesday night. The remarkable 22-year career was victim of the Reagan landslide that swept through the 2nd district in Maryland and pushed the 75-year-old Long into involuntary retirement that even some Democrats said was overdue.

Even in defeat, the white-haired former Johns Hopkins economics professor was philosophical, showing only glimpses of the curmudgeon's personality that had become his congressional trademark.

"I've always said that anyone who can beat me with all my years in the district and all of the work I've done I'll take my hat off to," Long said yesterday after conceding defeat to his three-time GOP challenger, Helen Delich Bentley. "Once you have been in for a long time and get to be an important person . . . people get itchy fingers and want to get rid of you."

From his perch as chairman of the prestigious House Appropriations subcommittee on foreign operations, he presented a formidable challenge to the Reagan administration's policies in Central America. Over the years, he became one of the most powerful and enigmatic figures in the House, a politician whose brilliance was inspirational but whose irascibility and stubbornness irritated even his closest colleagues.

He alternately amused, befuddled, antagonized, impressed and feuded with members of his own Maryland congressional delegation, where he served as the titular dean. His persistent opposition to dredging the Baltimore harbor, a position he reversed in 1981, resulted in long-term editorial combat with The Baltimore Sun and constant if subliminal tension with other Maryland congressmen. And his House peers tired of his insatiable appetite for publicity, particularly a chronic habit of elbowing his way in front of others to ensure that he was always in the camera's view.

But yesterday, in the aftermath of defeat, Democrats remembered his independent spirit more as a mark of courage and integrity.

"We will miss his independence and his clout," said Rep. Barbara A. Mikulski, a Baltimore Democrat who for years sparred with Long over harbor dredging.

In his 11 terms in office Long accumulated a lengthy list of conservative political enemies, most notably the Reagan White House and State Department.

He controlled the purse strings on aid to Central America and the Middle East and delighted in being a persistent thorn in the Reagan administration's side. Among his proudest accomplishments, Long said yesterday, was an agreement he made with Secretary of State George Shultz that forced the administration to launch an investigation into the murders of four American nuns in El Salvador several years ago.

One of the few members of Congress whose son served in active duty in Vietnam, Long developed an emotional zeal about war that reached epic proportions during his final terms in office. His son's experiences converted him from a supporter of the Vietnam war to a critic, and he was determined to prevent a similar American involvement in Central America or the Middle East.

He lambasted Reagan for stationing Marines in Lebanon and was reluctant to finance military operations in Central America. "I told the president to get those men out of there [Lebanon] and I was right," Long recalled proudly yesterday. "The men stayed and they were killed."

His feisty opposition to the president made him the bane of conservative foreign policy groups. "He was absolutely right at the top of my list of congressmen I wanted to see go," said Lynn Bouchey, president of the Council for Inter-American Security.

In the end Long became principally the target of the Republican party's congressional committee and of the nationwide assault on Democrats of a liberal stripe.

In retiring he is confident that he served his constituents well. Now he will move beyond Congress, he said, not to the world of academe that launched his career, but perhaps to writing a book about political economics.

His only concern, Long said, is that writing a book would be "harder work than politics."