Joseph G. Anastasi has resigned as secretary of Maryland's Department of Economic and Community Development, effective Dec. 2.

The action of the 40-year-old cabinet official was believed to be unrelated to his issuance last spring of a gloomy forecast for the state's economy, which Acting Gov. Blair Lee III sharply criticized, nor was it seen as a move by Lee to replace appointees of suspended Gov. Marvin Mandel with his own people.

Lee said he was "surprised" by Anastasi's decision, which he accepted "with deepest regrets" during a 30-minute meeting late Monday.

In his letter of resignation, Anastasi, a father of four, said his decision was dictated by a desire to establish a career outside government and by "the needs of my family."

He said later he believe that Lee should be free to name his own cabinet officers should he be elected governor next year, and if Lee should be-defeated, "I didn't want to go out a loser."

Anastasi has been with the department since its inception in 1969, except for a leave of absence in 1972 when he was trounced by then-Rep. Gilbert Gude (R) in the race for Congress in the Eighth District. He has been the $42,300-a-year department secretary for the last four years.

Lee criticized Anastasi in a speech last month, calling his pessimistic economic forecast "a masterpiece of statistics being manipulated to support a predetermined point of view." Yesterday, however, Lee praised Anastasi for doing "an excellent job."

Anastasi said he recommended that his deputy, William A. Pater, be prompted, a suggestion that he said Lee "didn't accept or reject."

Anastasi, who directed Mandel's campaign for governor in 1970, said he has no plans for employment, but is "hopeful an opportunity will come" now that he is making himself available. Otherwise, he said, he will return to his family real estate business in Silver Spring. He ruled out any campaign for public office next year, though he wouldn't discount that possibility for 1982.