MONTVALE, N.J. (AP) _ Joseph B. Flavin, who helped transform the Singer Co. from a sewing-machine maker into a leading aerospace and electronics concern, died Wednesday at age 58, the company said.

Flavin, chairman and chief executive of the company, became ill at his New Canaan, Conn., home Wednesday morning before he was to make his regular commute to Singer's offices here, and was pronounced dead a short time later at an area hospital, said Thomas Elliot, vice president for corporate relations.

Elliot did not know the cause or time of death. A company statement said Flavin died ''after a short illness.''

Singer elected William F. Schmied to succeed Flavin as chairman and chief executive officer, the company said. Schmied will retain his former position as company president.

Schmied, 58, has served as president and chief operating officer since 1980, and has been with Singer since 1969.

Under Flavin, Singer concentrated on aerospace electronics, which now accounts for more than 80 percent of the company's revenues.

In 1980, Singer shut its last U.S. sewing machine plant, which had been in business in the industrial New Jersey city of Elizabeth for more than a century. Last year, Singer spun off its former sewing operatins into a new company, SSMC Inc.

The company moved its executive offices in August to Montvale from Stamford, Conn.

Before becoming Singer's chairman, Flavin was president of international operations, executive vice president and a director of Xerox Corp. He also spent 14 years in executive posts with International Business Machines World Trade Corp.

''Joe Flavin's contributions to Singer were outstanding in their scope and impact in strengthening the company and positioning it for an excellent long- term future,'' Schmied said. ''We all feel a deep sense of loss and regret.''

Flavin, born Oct. 16, 1928, received a degree in business administration from the University of Massachusetts in 1953 and a masters degree from the Columbia University Graduate School of Business in 1957.

He is survived by his wife, Melisande; a son, Patrick; a daughter, Shawn; and six grandchildren.