LISBON, Portugal (AP) _ Prime Minister Anibal Cavaco Silva replaced five ministers in his center- right government Tuesday, two weeks after his Social Democratic Party suffered heavy losses in nationwide municipal elections.

Those dismissed include Eurico de Melo, defense minister and deputy premier, and Finance Minister Miguel Cadilhe, architect of the economic liberalization program.

Cavaco Silva also replaced Health Minister Leonor Beleza, Agriculture Minister Alvaro Barreto and Jose Silveira Godinho, minister for internal administration.

All five were leading figures in the government formed after the party won general elections in 1987 with the first parliamentry majority since a 1974 revolution ended 48 years of authoritarian right-wing rule.

Tuesday's action was the first major change in the team Cavaco Silva recruited to reduce state control and modernize the country to fit in with the European Community, which Portugal joined in 1986 as the poorest member.

News reports said de Melo resigned both his positions when Cavaco Silva decided to replace the other four because of the loss to the opposition Socialist Party in municipal elections Dec. 17.

Socialist officials dismissed the Cabinet realignment as ''changing faces but not policies.''

Cavaco Silva presented five new ministers to President Mario Soares, who must approve the appointments. They include Miguel Beleza, brother of the outgoing health minister, who is to replace Cadilhe.

Despite strong economic growth since the 1987 election, high inflation and Cadilhe's abrasive style made him the least popular minister in opinion polls. A parliamentry enquiry last year rejected allegations that he had evaded taxes.

Miguel Beleza, a director of the Bank of Portugal, supports government plans to sell state-owned companies and reduce controls on the economy.

Officials did not reveal Cavaco Silva's choice as deputy prime minister, but government spokesman Fernando Lima said Carlos Brito would replace de Melo as defense minister.

Brito lost the race for mayor of Oporto in the December elections, in which the Socialists got 32 percent of the vote nationwide, 1 percent more than the Social Democrats.