President Carter, in a final "State of the Union" message to Congress, yesterday defended his accomplishments in office, but warned that the United States faces "some of the most serious challenges in the history of the nation" in its foreign relations.

In a 76-page written message to Congress, the president warned that while the situation in Poland has shown signs of stabilizing recently, Soviet forces remain poised and "could move into Poland on short notice."

Carter, who leaves office at noon Tuesday, began the message with a statement of how he believes he is leaving the country after four years as it president.

"The state of the union is sound," he said. "Our economy is recovering from a recession. A national energy plan is in place and our dependence on foreign oil is decreasing. We have been at peace for four uninterrupted years."

But, the president said, the nation still has "serious problems," including unacceptably high inflation and unemployment levels at home, and such serious challenges abroad as the Soviet invasion of Afghanistan.

Discussing foreign policy, Carter said his administration's policies had been directed at "three areas of change: the steady growth and increased projection abroad of Soviet military power; the overwhelming dependence of western nations . . . on vital oil supplies from the Middle East, and the uncertainty about the future stability of many developing countries.

"The central challenge for us today is to our steadfastness of purpose," the president said as he outlined "six basic goals for America in the world over the 1980s."

He said these should include a continued increase in U.S. military strength, a continued effort to resolve international economic problems, maintenance of the U.S. commitment to nuclear arms control and an adequate response by the United States to trends involving changes in the world's resources, environment and population.

"We must pay whatever price is required to remain the strongest nation in the world," Carter said. He predicted that "the real increases in defense spending probably will be higher than previously projected" and "may require a larger share of our national wealth in the future."

As the message was sent to Congress, there was a flurry of activity at the White House and elsewhere in Washington suggesting that a breakthrough in the long hostage crisis with Iran could be near.

In the message, Carter repeated standard administration positions and language on the crisis, asserting that "our patience is not unlimited and our concern for the well-being of our fellow citizens grows each day." including passage of his energy legislation, enactment of the civil service reform legislation, other government reorganization measures and the fact that "confidence in the government's integrity has been restored" during his tenure.

Carter defended his economic record, and, in discussing inflation, which he called "the most difficult economic problem I have faced," pointedly took issue with President-elect Ronald Reagan's contention that government spending is the prime cause of inflation.

"This inflation -- which threatens the growth, productivity and stability of our economy -- requires that we restrain the growth of the budget to the maximum extent consistent with national security and human compassion," the president said.

He said he had done this in his budget proposals, and added: "However, while restraint is essential to any appropriate economic policy, high inflation cannot be attributed solely to government spending. The growth in budget outlays has been more the result of economic factors than the cause of them."

Carter urged adoption of his national health plan -- one of several initiatives certain to be opposed by the Reagan administration -- as the "solution to the 30 years of congressional battles on national health insurance," and said overall of his tenure in office:

"I firmly believe that, as a result of the progress made in so many domestic and international areas over the past four years, our nation is stronger, wealthier, more compassionate and freer than it was four years ago. I am proud of that fact."