President Carter, forecasting a decade-long struggle to control inflation, asked the leaders of the nation's cities today to boycott firms that refuse to comply with the administration's wage and price guidelines.

Addressing the annual meeting of the National League of Cities here, Carter warned the urban officials to expect little new federal aid to their communities and appealed to them for "your understanding and your help to solve this problem once and for all."

The budget he will propose to Congress in January, the president said, "will disappoint those who do not take inflation seriously.

"It will disappoint those who expect protection from inflation, while someone else bears the burden," he continued. "It will disappoint those who think only of the next year and not the next decade. And it will disappoint those who expect constantly expanding number of federal programs and agencies."

Carter, in announcing his anti-inflation program, said he would use federal procurement policies to encourage businesses and unions to comply with the wage and price standards.

Asking that the nation's cities do the same, he told the urban officials, "the most important thing that cities can do to fight inflation is to make sure that all of the goods and services which you procure come only from suppliers that will certify that they are in compliance with federal wage and price guidelines."

He also asked the officials to reduce local regulations. He offered as an example the updating of outmoded building codes that he said are fueling inflation in housing costs.

The speech was among the president's toughest on the subject of inflation and its austerity message was received in silence by the several thousand local officials in St. Louis' Cervantes Convention Center. But it should have come as no surprise.

It had been preceded by a drumbeat of predictions by administration officials about budget cuts next year and warnings that no segment of society - even cities, which traditionally expect favorable treatment from a Democratic administration in Washington - will be immune from the spending restraints.

In delivering his message, Carter sought to underscore that point, telling the urban officials that the public outcries for checks on government spending and taxes "are demands that I cannot - and will not - disregard."

However, the president also promised that in reducing the federal deficit he will avoid "starving useful programs" and will not make "wholesale, arbitrary spending cuts." While the budget for the fiscal year that begins next Oct. 1 will contain "little money for new initiatives," he said, "I promise that the cities will bear no more and no less than a fair share of budget restraint."

Specifically, Carter pledged to reintroduce in Congress next year a proposal for a national development bank, which would funnel federal funds to cities for development projects. Congress did not enact the legislation this year.

Arguing that inflation is robbing city governments, like other consumers, of their purchasing power, the president told the local officials that their communities' futures are at stake in the anti-inflation effort.

"If effort, Carter added, will require imagination, sacrifice and "the patience to realize that we cannot afford everything that we want now."

Following his speech, the president attended a budget briefing for the National League of Cities board of directors. He repeated his inflation message and said that even defense spending - the one government activity for which Carter has pledged to increase expenditures - will not be immune from scrutiny by administration budget cutters.

"No aspect of the government will be sacred nor sacrosanct," the president said. "All of it will be very carefully examined, including the Defense Department, where I will make sure that every dollar spent is very carefully assessed and where we have the greatest return on the money that we spend."

White House press secretary Jody Powell said later that Carter was not backing away from his promise to increase defense spending by 3 percent more than the inflation rate next year, but intended to warn Pentagon officials that "there is no free pass for anybody."

Reaction to the speech by the urban officials attending the meeting was generally supportive.

Mayor Tom Moody of Columbus, Ohio, president of the National League of Cities, told Carter after his speech, "I can pledge to you that we will support you in the inflation fight."

Moody said later he was "pleased" with the president's speech. "He indicated an understanding of the problems we face and of our special concern with the impact (of federal cuts) on our budgets," the mayor said. Moody also expressed the relief echoed by other mayors that Carter had pledged to assess defense spending as closely as domestic spending.

Syracuse Mayor Lee Alexander said that before Carter spoke, "many of us felt we would be the victims" of budget slashing. But he said that "the president wiped out that fear" by indicating that "cities will not bear the brunt" of the cuts, just "their fair share."

However, Washington City Council Chairmen Sterling Tucker said, "Uncertainties and unsecurities still remain among city officials over whether there will be lack of growth.

"We support the president's efforts to slwo inflation, but we can't sacrifice the tools of urban revitalization - jobs, housing, schools, services and community development."

Herman P. Starkes, a councilman froy Youngstown, Ohio, and president of the National Black Caucus of Local Elected Officials, said his organization telegraphed Carter today asking for a meeting to try to persuade him not to cut domestic spending and to resubmit to Congress his proposal for special aid to cities with high jobless rates.