Portugal, which rules the tiny enclave of Macao on the Chinese coast, and China are expected to establish diplomatic relations in the next few days, Western diplomatic sources said today.

There was no immediate indication of whether Macao -- noted for its gambling, high life and annual grand prix race -- would remain under the Portuguese flag.

There was speculation in Peking that the enclave, ruled by Portugal since 1557, might return to Chinese sovereignty but keep its social and economic system as a signal to the Nationalist Chinese on Taiwan that China's leaders are sincere in their reunification offers.

China has had no ties with Portugal since the Communist takeover in 1949. Diplomatic sources said Lisbon had been seeking formal ties for some time.

The reports of imminent normalization of relations were backed up by the announcement this evening in Macao that outgoing governor, Col. Jose Eduardo Martinho Garcia Leandro, will visit Peking soon.

Col. Garcia Leandro visited south China in May, but did not go to Peking becaue of the absence of diplomatic relations.

Macao, with a population of about 270,000 living on an isthmus and two small islands on the Western side of the Pearl River delta, was for centuries the only Western enclave in China.

Its fortunes have been linked to those of the Portuguese empire, and it became a quiet backwater of commerce after Britain and other Western powers forced their way onto the Chinese mainland in the mid-19th century.

Although overshadowed in importance by the nearby British colony of Hong Kong, Macao has remained an important source of foreign revenue for China.

In 1974, Portugal indicated that it was willing to withdraw from Macao, but China replied that it had no desire at that time to alter the status of the enclave.

Recently a Chinese leader, Foreign Trade Minister Li Chiang, visited Macao and met Chinese millionaire Ho Vin, chairman of the Macao Chamber of Commerce and the unofficial link between China and the colony, 97 percent of whose inhabitants are Chinese.