Poland's chief government spokesman declared today that the expulsion Wednesday of a United Press International correspondent was a warning to other western reporters to avoid contacts with underground and other secret or criminal sources in the country.

Though vague on what sorts of contacts might get a journalist into trouble in the future, spokesman Jerzy Urban advised correspondents to steer clear of information passed to them through other than normal mail or officially approved delivery channels and to stick to subjects of general journalistic interest.

UPI's Ruth Gruber, summoned to the Foreign Ministry this morning to be told formally of her expulsion, was given two days to leave the country following an incident Tuesday in which two rolls of film, reported by authorities to have contained photos of Polish military installations, were sent to her on a train from the Gdansk area.

The film was intercepted by police after it had been passed to a UPI office assistant at a Warsaw train station. Gruber and other employes in the UPI's Warsaw bureau have denied knowing that the film may have included sensitive information. They still have been unable to determine who sent the package. Western diplomats and correspondents here are viewing the case as part of an apparent pattern of harassment against western news organizations in Poland.

Denying the existence of a government campaign against western media, Urban asserted that the decision to revoke Gruber's accreditation--rather than hold her as a witness or press charges in an espionage case said still to be under investigation--should be seen rather as a "gesture of good will" in view of currently badly strained U.S.-Polish relations.

With Urban at a press conference was a man identified as Jerzy Karpacz from the Interior Ministry's investigation bureau, who conceded that his investigation so far had provided no grounds to file criminal charges against Gruber.

But Urban said that Gruber had overstepped the legitimate bounds of interest of a foreign correspondent in Poland by showing interest in specific military affairs. Quoting from an internal UPI cable to Warsaw which Urban said was sent last August, he said Gruber had been encouraged in this direction by her New York headquarters.

"Miss Gruber offended those privileges which are given to journalists accredited in our country," Urban stated. "She was interested in news which generally is not published in press agencies."

The spokesman went on to link the case to what he said were U.S. aspirations to influence affairs in Poland. "Essentially the activities of many U.S. representatives in Poland, including some journalists," Urban said, "trespass clearly journalistic interests and they aim, either in the goals or the results, to shape interior relations in Poland."

"We simply want to direct the work of foreign correspondents to its normal dimension," Urban explained. "By normal dimension I mean gathering information concerning various spheres of the country's life, information aimed at general publication. But we think that journalists should not use their accreditations in Poland to gather information for specialized institutions that deal with the military, with weapons and so on."

"Journalists in a way," he remarked at a later point, "have become the representatives of the criminal opposition circles, or have become informers of the specialized services rather than of public opinion. I openly say that we shall use all the possible means of persuasion so that events of that kind are eliminated, since they damage the interests of the country."

Depending on the outcome of the government's investigation, Gruber may yet be indicted on espionage or other charges, Urban said. Karpacz, the Interior Ministry official, told reporters that his bureau was still trying to find out who had taken the photos and attempted to pass them to UPI.

Meantime, Anna Olszewska, the UPI office assistant who accepted the film packet from a conductor at a Warsaw train station, was released this afternoon after being detained for two days. No charges have been filed against her.