Langhorne A. (Tony) Motley, who has been appointed assistant secretary of state for inter-American affairs, ended his largely successful term as ambassador here on a sour note when he clashed with Brazilian politicians over U.S. policy in Central America.

Last week an exchange of letters between Motley and Brazilian congressmen of all parties degenerated into an argument in the National Congress that prompted its president, Flavio Marcilio, to censure the ambassador for "declarations that could be considered insulting" to the dignity of the house.

The affair began last month when 209 deputies of all parties signed a letter to the U.N. secretary general condemning U.S. policy in Central America. At least one copy was sent to Motley, an Alaska land developer who has been ambassador to Brazil since the beginning of the Reagan administration.

Shortly after he traveled to Washington for confirmation hearings, those deputies who signed the protest letter received a message from Motley defending U.S. policy in Central America.

At least 19 deputies from two opposition parties rejected Motley's letter as a "lapse of sensibility" and an unwarranted interference in Brazil's domestic affairs.

The affair came to a head last Thursday when Motley, who is to travel to Washington on Wednesday to take up his new duties at the State Department, paid a farewell call on the president of the Congress after similar visits to senior ministers.

Motley and Congress leader Marcilio were discussing remarks, made by the ambassador when he returned to Brazil after the successful conclusion of his confirmation hearings, that an embassy spokesman admitted were "flippant."

Opposition party leader Airton Soares then burst in with the intention of handing back Motley's letter, which he said was "indelicately phrased and offends protocol," according to reports of the meeting that have circulated here.

Motley's observation that the letter was written in a democratic spirit and that Soares was ignorant of U.S. policy prompted an angry inquiry from Soares whether Motley would "adopt a democratic position" toward Central America or "continue sending money to support bands of insurgents and mercenaries who aim to overthrow the legal governments of Central America." He apparently was referring to U.S. backing for groups fighting to overthrow the revolutionary Sandinista government of Nicaragua.

Motley's conciliatory handshake was refused, according to reports of the meeting, and afterward Marcilio issued a statement saying, "This chamber has received declarations that could be considered insulting, and that it rejects." The statement was applauded by both government and opposition deputies. Another complaint about Motley's "indecorous behavior" was to be sent to the Foreign Ministry.

A U.S. Embassy spokesman said Motley's letter was "very succinct and polite," and said his observation that Brazilian deputies had signed a protest note without reading it had been confirmed by several letters the embassy had received apologizing to him for this oversight.

"It's unfortunate his departure should be on a sour note," said the spokesman, who added, "It was not meant to be a confrontation as such . . . . This confrontation has been ratcheted up by the other side, who are friends neither of the U.S. nor the ambassador."

Confining the incident within the context of Brazilian-U.S. relations the spokesman said, "I don't think he's going to carry on in this style. It doesn't have much to do with Central America, but more with Brazilian sensibilities about alleged U.S. interventionism." He predicted a lower public profile for Motley at the State Department than in the U.S. Embassy in Brasilia.

Motley's scant respect for diplomatic protocol long has upset congressmen and people in Brazil's Foreign Ministry, who watched him skillfully cement U.S.-Brazilian relations through direct and informal contacts with President Joao Baptista Figueiredo, at whose residence the ambassador frequently appeared for weekend barbecue lunches.