House Democrats voted yesterday to allow Rep. G.V. (Sonny) Montgomery (Miss.), a leader of the party's conservative "Boll Weevil" faction and a consistent supporter of President Reagan's economic program, to retain the chairmanship of the Veterans' Affairs Committee, letting him off with what amounted to a warning.

The Democratic caucus voted, 179 to 53, to allow Montgomery to retain the post after the conservative Democrat pledged loyalty to the party and conducted a personal campaign for support among his colleagues.

"We got the message," Montgomery said after the secret ballot. "I like being a Democrat."

The vote was in sharp contrast to the decision Monday by the Democratic Steering and Policy Committee to take away the Budget Committee seat of Phil Gramm (Tex.).

Unlike Gramm, Montgomery personally campaigned for support among Democratic colleagues, stressing his willingness to lend political support to liberal and moderate members. In addition, he had strong backing from veterans organizations.

Gramm and Montgomery had almost identical voting records, but Gramm made no pretense of repentance for supporting the president. He also appeared to welcome the rejection by party colleagues because it helps to justify an anticipated shift to the GOP and the start of a possible statewide race by him in Texas in 1984 or 1986.

Montgomery won nomination for the committee chairmanship by only a 16-to-11 vote in the steering committee. In the full caucus vote, however, he was supported by key Democratic leaders, including House Speaker Thomas P. (Tip) O'Neill Jr. (D-Mass.).

Montgomery, who told colleagues that he wants to remain a Democrat, worked during the recent election campaign for several conservative and liberal Democrats. After the caucus vote, he said he remains a conservative and did not indicate that his voting patterns will change.

The caucus reelected all other incumbent committee chairmen by overwhelming margins, although 18 votes in the secret balloting were cast against both Budget Committee Chairman James R. Jones (Okla.) and Ways and Means Committee Chairman Dan Rostenkowsi (Ill.).

The steering committee also voted to give Buddy Roemer (La.), another Boll Weevil, a seat on the Banking, Finance and Urban Affairs Committee. The nomination is subject to approval by the full caucus.

Just before the committee vote, Roemer had said: "If I don't get on the banking committee, and Republicans make that offer, that would be very tempting." He was referring to a GOP offer nearly two years ago to give him a banking panel seat if he switched parties.

The steering committee nominated to the influential Energy and Commerce Committee six members whose addition, combined with loss of slots held by conservative Republicans, appears to represent a victory for environmentalists preparing for a major battle this year over the Clean Air Act.

Nominated were Wayne Dowdy (Miss.), Bill Richardson (D-N.M.), Jim Bates (D-Calif.), Dennis E. Eckart (D-Ohio), Jim Slattery (D-Kan.) and Gerry Sikorski (D-Minn.).

Sources said Republicans selected Jack Fields, elected two years ago with strong support from the oil industry, to fill one of two GOP vacancies on Energy and Commerce. The Democratic choices represented a defeat for Committee Chairman John D. Dingell (Mich.), who had reportedly been backing Dennis M. Hertel (D-Mich.). Hertel would have been expected to join Dingell in support of the automobile industry during consideration of the Clean Air Act.

Another major loser was the coal industry as West Virginia's Alan B. Mollohan and Harley O. Staggers Jr. and Virginia's Frederick C. Boucher failed to win seats.

Other Democratic nominees included Timothy J. Penny (Minn.), Richard J. Durbin (Ill.), Lane Evans (Ill.), Lindsay Thomas (Ga.), Robert M. Tallon Jr. (S.C.) and James R. Olin (Va.) to the Agriculture Committee.

Also nominated were Richard Lehman (Calif.), Bruce A. Morrison (Conn.), Jim Cooper (Tenn.), Marcy Kaptur (Ohio), Ben Erdreich (Ala.) and Sander Levin (Mich.).

In the Senate, GOP leaders began exploring a suggestion from Majority Leader Howard H. Baker Jr. (R-Tenn.) that Congress recess during July and August to hold nationwide hearings on public reaction to the budget and other legislative issues.

Baker, long an advocate of shorter congressional sessions and more time for contact between legislators and those they represent, brought up the idea at a meeting of Senate committee chairmen and reportedly intends to pursue it with leaders of both parties in both houses.