The Congress giveth, and the Congress taketh away. Or so it must seem to a number of Senior State Department officials who have just seen a tan talking promise of early retirement flash across their vision and then disappear in an odd plece of now you see it, now you don't congressional sleigh hand.

The story began early this month when Congress, in an effort to ease an overpopulation problem in the upper reaches of the department, passed legislation that offered career foreign service personnel a special, for-a-limited-time-only chance to retire early on attractive financial terms.

For many, it was an offer that they couldn't refuse. Of the roughly 1,000 officers in the foreign service's top three grades, 34 immediately sent in their letters of resignation. Joining them were an additional 14 officials from the Agency for International Development and 16 from the International Communication Agency.

Then, Congress suddenly reversed itself.

Congress didn't get around to the foreign service until 4 a.m. Sunday. But, when it did, it wiped its earlier retirement offer off the books. Moreover, it did so in a way that left the question of who's entitled to what benefits in such utter confusion that the matter may eventually have to be resolved by the federal courts.

Since Sunday, at least 15 of those who put their retirement papers in have hastily snatched them back and announced their intention to stick around. Most of the others are still pondering whether to do the same or stick with their retirement plans and let the courts decide how big a pension they should be getting.

Among them are six very senior officials who recently have served as ambassadors or held top policy-making jobs: Theodore L. Eliot Jr., former inspector general of the foreign service: Wills Stabler, former ambassador to Sapin; Robert Dean, former ambassador to Peru; Richard L. Sneider, former ambassador to South Korea; Fred Irving, present ambassador to Jamaica and former assistant secretary for oceans and enviromental affairs, and Francis Underhill, former ambassador to Indonesia and Malaysia.

Despite their high ranks, most have recently had trouble in getting major assignments - a situation that department officials say is due not to lack of ability but to the fact that the United States currently had more senior diplomats on active duty than it has jobs for them to fill.

That's due to several factors, chief among them Congress' action last year in raising the pay of top-ranking career government officials from around $39,000 a year to a range of from $47,500 to $50,000.

Since government service pensions are calculated on the average of the retiree's three highest-earnings years, many foreign service officers who might otherwise have retired elected to stay on and get three years in at the higher scale.

Complicating the situation further were a court decision barring the State Department from forcing people to retire at 60, the shelving of the department's once rutless system of "selecting out" officers with low efficiency ratings and the Carter administration's tendency to fill many top diplomatic jobs with outside political appointees.

The net effect was to create what department officials call "a bulge" - an excess of officers at the top that has forced many to take jobs normally held by people of lower rank and that has blocked many younger officers from promotion and advancement.

To help ease the problem, Congress two weeks ago tacked a special retirement provision onto the fiscal 1979 State Department authorizaition bill. It specified that any foreign service officer retiring between Oct. 1 of this year and Dec. 31, 1979 could have his pension calculated on the basis of his single highest year's salary.

Despite reservations that it would set a percedent for the rest of the federal service and help to fuel inflation, President Carter signed the bill. The result was the rush of 64 retirement applications in less than two weeks. (Department officials say the normal retirement rate in the foreign service is about 40 a year.)

But, in the course of the present Congress' closing hours, opponents of the plan tacked two countering amendments onto the fiscal 1979 foreign aid bill. One simply would repeal the special retirement plan, and the other would bar payment to anyone whose pension is computed on the basis of a single year's salary.

The result, department officials say is that they don't know where anybody who tried to retire since Oct. 1 stands.

To solve the problem, the officials say, they hope either for some new legislation when Congress returns in January or a clarifying opinion by the General Accounting Office. Otherwise, they predict, the result is likely to be a lot of costly and confusing lawsuits against the government.