President Jimmy Carter and Senator Edward M. Kennedy both attended a political function last night and watched another man take the spotlight. But while they were wishing Speaker of the House "Tip" O'Neill a happy 67th birthday, the two candidates for the Democratic presidential nomination managed to slip in a few one-line political punches.

Kennedy cited Carter's opinion that presidents should serve one six-year term and said, "We are only two years apart on this issue." Carter thanked O'Neill for teaching him "a principle which is fundamental in American politics -- that you wait for your turn."

O'Neill, having climbed the slippery slope of his 67th year, with a little help from about 1,000 friends at a birthday party, found a chair waiting for him at the top.

It was the Thomas P. O'Neill Jr. Chair in Political Science, to be supported by the income from an endowment of approximately $1 million, established by his alma mater, Boston College, where political science is the most popular major field in the college of arts and sciences.

"Imagine the idea of teaching politics to Irish kids in Boston," said Dinah Shore, who served as mistress of ceremonies at the party, where nearly $1 million worth of sirloin, potatoes, carrots and broccoli was consumed at $1,000 per plate.

Kennedy began talking politics with the opening sentence of his tribute to O'Neill: "It's a pleasure to see so many friends and supporters and President Carter." He said he had talked recently to the president's mother, Miss Lillian, "and she told me that the president had been working very hard for three years and needed a rest. I told her I was in complete agreement."

The applause welcoming Carter was not quite as loud as Kennedy's, but lasted approximately three times as long, and it started all over again when the president said he had decided to attend despite "some very important business in Iran."

When he was first invited, he said: "my immediate and firm presidential response was, 'I an not going to any fund-raising events this month.' Then Frank Moore, my congressional liaison, said 'Mr. President, the speaker thinks you should be there,' So, it is my great pleasure to be here tonight . . ."

He recalled that O'Neill had shared an apartment with classmates and fellow congressman Edward Boland (Did an apartment with classmates and fellow congressman Edward Boland (D-Mass.) "for 23 years before deciding that his seat was secure enough to bring his wife, Millie, down here."

"Tip," he said, "there's no need to worry. The voters of the Eighth District recognize the value of the principle -- which I share with you -- of reelecting the incumbent."

He may have implied a more serious criticism of the senator when he referred, three or four times, to the "united" American position on the problems in Irna. "I have no doubt that we in America will prevail," he said, "because we are right, because we are strong, because we are united."

Most of the evening's humor was supplied by Dinah Shore, who apologized for the absence of California Gov. Jerry Brown, the third candidate for the Democratic nomination. "He was supposed to be here," she said. "He's not in California. He's never in California.

She added that "Linda will love" a new home that the governor is building.

Reporting on a survey of opinion about O'Neill, she said he is considered "the second most important man in Washington, next to Joe Califano. Joe Califano told me that at a football game this afternoon."

Explaining some of President Carter's political troubles, she said that "until a few months ago, the White House thought a House speaker was something you bought at the Radio Shack."

She said that Carter had told her, "I think Tip O'Neill is a magnificent congressman and a great speaker of the House -- but just between us, Dinah, don't you think he has a funny accent?"

The Boston College accent (which differs subtly from the Harvard accent) is not all that uncommon in Washington. Including O'Neill, the Jesuit university now has six alumni representing Massachusetts in the House of Representatives, which gives it a delegation equal to or greater than those of 26 of the American states. There are even two Republicans in the delegation -- Silvio Conte and Margaret Heckler, both of whom had seats at last night's celebration.

The party reached its climax when an enormous birthday cake was wheeled in by four waiters, bearing an equally enormous portrait of O'neill in icing on the top. After Dinah Shore had led the crowd in singing "Happy birthday dear Ti-ip", O'Neill approached the cake, knife in hand, looked at the portrait and hesitated. He finally cut a small slice from an edge of the cake, far away from the portrait, gave bites to his wife and the president, and turned to describe the picture to those who could not see it:

"I see this guy with bushy white hair, eyebrows of about the same color, and that nose -- my God, you ought to take a peek at it."

Then he hesitated: "I ain't got a damn thing to say, Dinah -- will you take it over?"

So Dinah Shore introduced Bobby Short, who began to sing "Sunny Side of the Street," barely audible in the political chitchat and the birthday cake was wheeled backstage -- almost untouched.