An undercover FBI agent testified here today that he paid former Atlantic City mayor Michael J. Matthews $14,000 for Matthews' help on two projects, including a casino sought by organized crime.

Agent James Bannister, taking the stand at Matthews' corruption trial in U.S. District Court here, said he handed Matthews most of the cash in his city hall office on two occasions last year.

Bannister also testified that an Atlantic City crime family, headed by Nicodemo (Little Nicky) Scarfo, made $125,000 in contributions to Matthews' 1982 mayoral campaign. In exchange, Bannister said, Matthews "indicated they would receive certain favors from time to time."

Matthews, who was ousted in a recall election in March, is charged with using his office to aid organized crime and extorting bribes from Bannister for helping two corporations -- actually fronts for the Federal Bureau of Investigation -- obtain city contracts and purchase city land for a casino. Matthews, 50, faces 85 years in prison if convicted.

The trial has highlighted the extent to which organized crime has infiltrated Atlantic City since it became the East Coast's casino-gambling capital eight years ago. Federal prosecutors say the mob has penetrated the seaside resort through hotel and construction unions, despite efforts of hundreds of federal and state law-enforcement agents.

The heart of the government's case is 326 FBI tape recordings, many picked up by a microphone strapped to Bannister's back. During the four-year investigation he posed as businessman James Biacco, a representative of a Washington-based investment firm that actually was run by the FBI.

Bannister testified today that he told Matthews that he also represented the Piedmont Group, another FBI front that was seeking to acquire a 21-acre tract of prime city land for a casino.

Last November, Bannister said, "I paid Mr. Matthews $10,000 . . . in the form of cash. It was for his assistance in putting up some city-owned, casino-zoned property for sale.

"I promised him Piedmont would give him an additional $10,000 cash and a 1 percent interest in whatever was developed on the property," Bannister added. He said this secret interest would be worth "a minimum of $200,000."

In a tape-recorded conversation last November at Atlantic City's Peking Duck restaurant, Matthews assured Bannister that city planning officials would approve Piedmont's use of the land. "That's mine," Matthews said. "No problem with the planning board. Whatever you want with the planning board."

Bannister testified that he also made $13,000 in payoffs to Frank Lentino, whom he described as a Scarfo lieutenant. The government said the Scarfo group also had a hidden interest in the casino. Lentino, a leader of Local 54 of the Hotel and Restaurant Employes Union, pleaded guilty to conspiring with Matthews and organized crime before the trial began last week.

Bannister told the 12-member jury that Matthews also aided an FBI front called Flag Chemical, a janitorial supply firm, after he had Lentino pay the mayor an initial $1,000 in marked bills. In April 1983, Bannister said, "I gave Mr. Matthews $3,000 cash on behalf of Flag Chemical. It was in a white envelope. It was hidden in Atlantic City magazine. I was in the mayor's office at that time.

"It was for Mr. Matthews' assistance in gaining part of the janitorial supply contract with the city of Atlantic City for Flag Chemical."

On Wednesday the jury heard a taped conversation in which Matthews and Bannister discussed the $3,000 payment, and Matthews said he would provide Flag Chemical with information about competitors' bids.

W. Hunt Dumont, U.S. attorney here, said in an interview that Matthews had "agreed he would deliver his office to the Scarfo organization in exchange for $125,000 in contributions to his campaign. He would render assistance to projects of interest to the organization, as well as to businesses that were willing to pay off both the organization and the mayor."

The FBI said that Matthews confessed to the scheme and agreed to cooperate with the investigation in a long late-night confrontation with its agents last December, but that he later backed out of the agreement. U.S. District Court Judge Harold A. Ackerman has ruled that the confession may be admitted as evidence.