HAMBURG, West Germany (AP) _ Police are investigating whether 152 Sri Lankan refugees rescued off the coast of Newfoundland came from a town near here, a spokesman said today.

Police in Stade, eight miles from Hamburg, are checking the residences of all registered refugees from Sri Lanka after a West German state legislator said a group of Sri Lankans had left the area last month.

''We are checking who is still there, who is gone, and where did they go? Are they in Canada, or just visiting friends?'' said police spokesman Hans- Juergen Gevers.

A West German state legislator, Rudolf Fischer, said Wednesday a group of Sri Lankan Tamils left the Hamburg area July 27 bound for France, where they were to board a freighter for Canada.

Officials in Canada have been trying to determine where the 152 Tamil refugees rescued off Newfoundland on Monday began their journey. The refugees, who were in open lifeboats, say they boarded a freighter in India, but West German documents and money were found on some of them.

In Bonn, a spokesman for the Interior Ministry said the government needs more information about the Tamils, including their identities, before it can determine whether they lived in West Germany.

''We have over 30,000 people from Sri Lanka seeking political asylum here,'' said the spokesman, Michael Butz. ''If we just had 160, it would be easier to determine whether they came from here.''

A Foreign Ministry spokesman, Hans Schumacher, said 37,000 Sri Lankans have sought political asylum in West Germany since 1980 and that most have been turned down.

Schumacher said he has asked the West German Embassy in Canada to obtain more information from Canadian police.

A Newfoundland fishermen involved in the rescue had said some of the Tamils were wearing life jackets with Hapag-Lloyd written on them, Canadian reports said.

Hapag-Lloyd is a major shipping line based in Hamburg, whose container ships make regular calls in Halifax, Nova Scotia, and New York City.

But a Hapag-Lloyd spokesman told The Associated Press it was unlikely that 152 people could be smuggled onto one of the company's container ships.

''For 152 (people) one needs at least six containers,'' spokesman Gerhard Simonsen said. ''They could not be easily smuggled on board, and they would have to have been locked into the containers, which are not opened during the trip.''

Tamils, a mostly Hindu minority on Sri Lanka, complain they are persecuted by that country's Buddhist Sinhalese majority. Militant Tamils are fighting a guerrilla war for independence in northern Sri Lanka.