Secretary of State Alexander M. Haig Jr. said today that talks will begin soon on a possible agreement permitting U.S. planes to land and refuel at Moroccan air bases during periods of military emergency in the Middle East.

The possibility of access to Moroccan air bases is especially important to U.S. military planners seeking to put together a Rapid Deployment Force able to respond quickly to crises threatening Western interests.

Haig, noting that the growth in U.S.-Moroccan military relations "requires a more formal structure to address security matters," also announced that the two countries are planning a joint military commission to "meet periodically for consultations."

While Haig stressed that no decisions had been taken on the bases issue, Moroccan Foreign Minister Boucetta Mohammed said, "We fully agree with what the secretary says regarding security and related matters."

Haig held two days of talks with King Hassan II aimed at drawing this North African kingdom closer into the web of military understandings that the United States is trying to create throughout the Middle East.

The secretary has described this so-called "strategic consensus" as a series of separate, cooperative arrangements with pro-Western states that share the Reagan administration's concern about threats to the region from the Soviet Union and its surrogates.

Because of sensitivities rooted in their colonial past, most Middle Eastern countries are unwilling to permit the United States to maintain bases within their territory. That has forced Washington to plan the Rapid Deployment Force as an "over-the-horizon presence," located outside the region and dependent, in cases where it would be employed, on the ability to have landing, refueling and storage facilities within friendly countries.

After saying that in the case of Morocco, "no decisions have been made," Haig added that "a positive and effective basis has been established" for discussions about "two specific, possible facilities" within Morocco.

He did not elaborate. However, the secretary was believed to be referring to two of the four bases maintained by the United States here during the 1950s. These were given up by Washington in 1963, and two of the facilities now are used by the Moroccan Air Force. The largest, Nouasser, is now Casablanca's international airport.

Haig was even more cautious in talking about the purpose of the joint military commission. On a visit to Saudi Arabia earlier this week, Defense Secretary Caspar W. Weinberger announced plans for a similar commission with the Saudis.

However, the Saudi Defense Minister, Prince Sultan, appeared anxious to downplay the agreement and did not even mention it in his public appearances with Weinberger.

The enthusiasm expressed by Morocco appeared to stem, at least in part, from Hassan's desire to obtain increased U.S. military assistance to pursue his war against Algerian-backed guerrillas in the disputed Western Sahara.

The United States officially is neutral in the conflict. But, because of its desire for Hassan's cooperation in "strategic consensus," the administration hopes to win a substantial increase in military aid for Morocco in the next fiscal year. Haig refused to cite a figure.

"Our experience was disappointing in fiscal 1982," when Congress cut the administration's request for Morocco back to $34 million in military sales credits, said Haig. Citing the threat allegedly posed by the expansionist activities of Libya in northern Africa, he added, "I hope we will be able to do better in the 1983 fiscal year."

Haig also implied that efforts to entice Hassan to visit Washington will succeed before summer.