The National Hockey League found a friend yesterday. President Reagan invited NHL officials and the 40 members of the two All-Star teams to lunch at the White House, then showered unaccustomed praise on the sport.

"Ice hockey may once have been overlooked, but today, thanks to the dedication of many of you right in this room, hockey is beginning to get the attention it deserves," Reagan said.

The president quickly made it clear he was not referring to the negative publicity that has accompanied some violent incidents this season.

"Recently, hockey has received its share of criticism, but as often happens, many hours of fine sportsmanship are often overlooked because of a few moments when tempers grow short," Reagan said. "Hockey is such a majestic contest, let's hope in the future public attention will focus on the nobler aspects of the sport. The players with us today, for example, have been selected as the best of your profession. I'm certain they stand shoulder to shoulder with the top athletes in the world."

All those kind words were too much for NHL President John Ziegler, who said, "I don't think we can handle the honor that has been paid to our sport."

Reagan recalled brief hockey experience of his own, when he laced up skates and performed with members of the NHL New York Americans in 1939 for scenes in the movie "Hell's Kitchen."

"It featured a group of delinquents called The Dead End Kids," Reagan recalled. "They were as wild off the screen as they were on. After dealing with them, I can assure you I have the deepest appreciation of how hard it is to keep peace on the ice."

Ziegler referred to Reagan's brief hockey experience when he presented the president with an All-Star jersey, No. 1 with REAGAN stitched on the back.

"We heard of the president's hockey prowess and at that time you wore the uniform of the New York Americans," Ziegler said. "We were concerned that the jersey had worn out, so we've brought you a new one."

Reagan also received a replica of the Stanley Cup and joked, "I heard some mention of this and I thought the cup I was getting was the real thing. I was anxious to have it displayed here."

Seated with the president were Speaker of the House Tip O'Neill, a fan of the Boston Bruins; Allan Ezra Gottlieb, Canadian ambassador to the United States; Bill Wirtz, chairman of the NHL Board of Governors; former hockey stars Gordie Howe and Phil Esposito; Ziegler and superstar Wayne Gretzky.

Reagan told a couple of hockey jokes aimed at dining partners.

For O'Neill's benefit, he related a gag about Knute Rockne:

"The Carnegie Foundation made a report on violence in sport and asked Knute Rockne, 'Why do you emphasize a violent sport like football? Why not emphasize something less violent?' 'Like what?' Rockne asked. 'How about hockey?' was the reply. Rockne said, 'I once suggested hockey to the president of Notre Dame and the president said Notre Dame would never back a game that puts a club in the hands of an Irishman.' "

For Gretzky and Vice President Bush, who presided at another table, Reagan told this one:

"Rumor has it Wayne, that Washington has been trying to trade and get you. I asked what Edmonton is getting in return and they told me two first-round picks and the State of Texas."

"That's all?" piped up a voice in the audience.

Gretzky, a bit overwhelmed by all the attention, was asked what he had said to the president during the meal of crab bisque, cheese straws, roast tenderloin of beef, mushrooms and potatoes Mascotte, tomatoes St. Germain and NHL cake.

"I remember Gordie (Howe) told me 10 years ago that you have two ears and a mouth and you should learn to use all of them. Today I made use of the ears."

Reagan made special note of Buffalo defenseman Mike Ramsey, making his second White House visit. Ramsey was a member of the gold-medal United States Olympic hockey team in 1980, which was entertained by President Carter.

"The victory of the U.S. Olympic hockey team over the Soviets at Lake Placid back in 1980 is a vivid memory cherished by the American people," Reagan said. "In fact, 10 of those boys of Lake Placid are now playing on NHL teams. One of them, Mike Ramsey, is with us today. Mike, congratulations on making the All-Star team."