Secretary of Defense Caspar W. Weinberger and Secretary of State George P. Shultz have delivered a blunt, private warning to President Reagan that the balanced-budget bill he has endorsed could mean deep cuts in military spending, foreign aid and counterterrorism programs, administration offficals said yesterday.

In a move that underscored a deep split in the administration, Shultz and Weinberger wrote to Reagan this week of the "serious consequences" the Gramm-Rudman-Hollings legislation would have on national-security programs, one official said.

National security affairs adviser Robert C. McFarlane took their appeal to Reagan and told the president he also supported it, officials said.

Reagan has strongly backed the legislation. One aide said Reagan "thinks it's the greatest thing since sliced bread." The bill has received enthusiastic backing from White House chief of staff Donald T. Regan and Office of Management and Budget Director James C. Miller III, who has disputed claims it would result in deep cuts in defense spending.

Despite the letter from Shultz and Weinberger, a White House official said Reagan's basic support for the bill is unwavering and that he has tentatively decided to devote his radio address Saturday to the subject.

The bill, sponsored by Sens. Phil Gramm (R-Tex.), Warren B. Rudman (R-N.H.) and Ernest F. Hollings (D-S.C.), would set targets for balancing the budget by 1991 and would require automatic cuts in programs, including defense, if the targets are not met by the president and Congress.

Reagan has qualified his support for the bill by saying he does not want to scale back his military expansion. One official said Reagan reiterated this view when the letter was presented to him. "Reagan wants to protect defense just as much as they do," this official said.

But Weinberger and Shultz, who both served as federal budget directors in the Nixon administration, suggested in the letter such cutbacks could not be avoided and would be forced by Congress.

"We're talking about very large numbers here," said a senior official. The two secretaries "want to be sure" Reagan is aware of "what he'd be dealing with in November and December" if the legislation is approved.

McFarlane is said to have argued to the president that defense spending is almost certain to come under attack on Capitol Hill in the months ahead and that the balanced-budget legislation offered no protection for the military buildup.

Weinberger and Shultz "did not offer a solution," such as suggesting that Reagan abandon the bill, the senior official said. But they reportedly told the president that the "original sale" of the bill to him included "different things" than the version now being considered.