Former Alexandria prosecutor William L. Cowhig was questioned yesterday by a federal grand jury investigation illegal gambling, massage parlors, and alleged political corruption in the city he once served.

"I have received a subpoena from the federal government and I am prepared to bare my soul for the grand jury," Cowhig said shortly before entering the third-floor grand jury room. However Cowhig, who recently moved to Florida declined to say after his 65-minute grand jury appearance whether he had been named a target of the year-long federal probe. Nor would he say what kinds of questions he had been asked.

Cowhig, who sources said has been under the grand jury's scrutiny, was acquitted twice in the last eight months by Alexandria trial juries of bribery and gambling charges. He resigned the prosecutor's office in February when a second gambling charge against him was dropped.

Cowhig yesterday appeared suntanned and nattily dressed in a blue and white and white checked shirt with epaulets and gray slacks. He carred a brown vinyl briefcase with him into the grand jury room.

Asked about his testimony later in a corridor outside the hearing room, Cowhig said, "You'll have to ask Mr. Hein, you'll have to ask him," referring to FBI agent Albert F. Hein Jr. who stood nearby. Hein, who also refused comment, has investigated controversial bingo game operations in the city during the past year.

According to documents filed in connection with the case, Cowhig was subpoenaed so he could authenticate tax documents, bingo game receipts, and payment records regarding a hotel in the Bahamas he owns with members of his family.

Cowhig also is being investigated by a state bar ethics committee regarding allegations that he accepted sexual favors from the wife of a defendant he was prosecuting.

After his own testimony was concluded, Cowhig waited at the U.S. District Court building in Alexandria until his widowed mother, Mary B. Colasanto, had finished her testimony before the grand jury.

"They are asking her about gifts I gave her like a gold necklace, but told them (federal investigator) that the necklace only cost $60," he said.

Cowhig has previously said that it was his mother who gave him the money he used in 1971 to purchase the Bahamian hotel, known as the Two Turtles, for $172,500.

Federal officials have long been investigating the small foreign hotel and Cowhig's frequent trips there by private plane while he was Alexandria's chief prosecutor.

Cowhig yesterday criticized a recent trip to the hotel by federal officials. "They sent an FBI agent, and IRS guy, a Customs official, and some others. I could have told them everything they needed to know. What a waste of tax-payers' money," he said.

Cowhig was elected prosecutor in 1973 and reelected without opposition four years later. During his years in office, massage parlors and bingo games flourished in the city at the same time other Northern Virginia localities were imposing tighter controls on them.

A massage parlor ring based in Alexandria and run by entrepreneur Louis Michael Parrish, who was convicted last March, last year grossed more than $1 million.Bingo games in the city reported total grosses of more than $1.2 million annually, according to official documents.

James I. Burkhardt, an Alexandria lawyer who once represented Parrish, has been told he is a target of the grand jury. Parrish himself has testified before the panel. Yesterday a parade of witnesses connected with Northern Virginia bingo operations also appeared before the grand jurors.

These witnesses included convicted bingo operators Alva Ford Thompson, and James R. Fike, who was granted immunity in exchange for his testimony. Allen Palmore, another operator who testified at one of Cowhig's traisl, also has been subpoened.

Anita Woods, a volunteer worker at Bingo games run by the Montessori School of Alexandria, Inc., carried a suitcase full of documents with her into the grand jury room yesterday. Woods declined comment afterward.

Cowhig was acquitted last December of charges he asked for and received $32,000 in bribes from the operator of the Montessori game.

Richard L. Mathews, a city health inspector, said after his appearance yesterday that he testified he had once declined a bribe from a massage parlor operator. He refused to name the individual to reports.

The grand jury is expected to return next week, and then recess until September.

Cowhig said yesterday in Daytona Beach and negotiating to purchase a retail bakery store. Cowhig said he has become religious since his legal problems began, and added yesterday he was "fortunate" his new home is located next to a Catholic Church. CAPTION: Picture, WILLIAM L. COWHIG . . . returns from Florida