The Democratic-controlled House, brushing aside last-minute charges from President Reagan that it is taking "unacceptable risks with our national security," voted 245 to 179 yesterday to approve a fiscal 1987 budget that would sharply cut the administration's proposed military spending for next year.

The vote was largely along party lines, with 17 Republicans supporting the Democratic budget and 19 Democrats voting against it. The essentially partisan vote sets the stage for what seems to be emerging as an equally partisan fight over continuation of the administration's rearmament program.

Republican support for the measure also appeared to fall short of the bipartisan backing that House Democratic leaders had been demanding for enactment of tax increases. And, even before the vote, House Speaker Thomas P. O'Neill Jr. (D-Mass.) reaffirmed his insistence that Reagan must "embrace" tax increases before Democrats would support them.

The nearly $1 trillion House budget follows the general outlines of a bipartisan plan adopted last month by the Republican-controlled Senate. But the two versions differ in some key elements, which could cause problems in a House-Senate conference that may be called as early as next week to resolve differences.

Both come within the Gramm-Rudman-Hollings deficit target of $144 billion for next year. Both also would cut Reagan's defense spending request, scale back his proposals for domestic spending retrench- ment and call for tax increases of about $7 billion more than the president has indicated he is willing to accept.

But the House would cut Reagan's $320 billion defense request to $285 billion, with $3 billion held back until the Pentagon accounts fully for current spending. The Senate, meanwhile, would cut the president's request to $301 billion. The House level is about $2 billion below current spending authority for defense; the Senate would allow slightly more than enough extra spending authority to cover the costs of inflation next year.

While both houses basically would freeze domestic spending, they would achieve the savings in different ways and the Senate savings would be somewhat larger. The Senate proposes less than half the domestic savings that Reagan seeks; the House proposes about one-third. Generally, the House would protect or marginally expand a variety of poverty programs, especially those for children, the elderly and unemployed workers.

The House earmarked tax increases for deficit reduction, while the Senate used the extra revenue to increase defense spending. Moreover, the House, with a projected deficit of $137 billion, or $7 billion below the Gramm-Rudman-Hollings ceiling, allowed itself leeway to drop the tax-hike provisions if it feels the political need to do so.

But defense spending was the battle ground upon which Reagan and congressional Republicans chose to fight, over objections from Democrats, who contended that the difference in actual outlays for defense between the House Democratic plan and a Republican alternative is only about 2 percent over three years.

The GOP alternative, which was rejected on a basically party-line vote of 280 to 145, would have provided $293 billion for defense, still $27 billion short of Reagan's request, but $8 billion more than the Democratic offer. It also would have rejected tax increases beyond what Reagan wanted and would have cut more deeply into domestic programs than the Democrats would.

In a letter to House Minority Leader Robert H. Michel (R-Ill.), Reagan called the Democratic plan a "radical anti-defense budget" that would "tear down much of what we have built, together, these past five years and return us to that era of the 1970s when the national defense was neglected and our country paid world-wide and dearly for that neglect."

It is, he said, a "breach of faith with our common duty to protect this nation" that would "cripple the combat readiness of our conventional forces and take unacceptable risks with our national security at time when the immense Soviet military buildup continues uninterrupted."

He said "program terminations and cancellation of proposed new starts would be unavoidable," adding that cuts would include "an entire division from the Army, an aircraft carrier battle group and tactical fighter wings from both the Air Force and Navy. Improvements in rapid, long-distance deployment of forces would be postponed, research on more than 50 programs would be shelved or stretched out, more than 25 weapons programs would be delayed and munitions support for troops in combat would be jeopardized.

"In short," he added, "the impact on our defense capability would be pervasive and severe across-the-board."

House Budget Committee Chairman William H. Gray III (D-Pa.), contending that the differences between Republican and Democratic versions of the budget are "very small" in defense, accused the administration of "posturing" and warned that it is courting the "disaster" of stalemate by continuing to refuse to compromise on defense.

Differences between the Democratic and GOP proposals would amount to about $17 billion over three years, he said, adding, "No one should think that, because of a $17 billion difference, the Russians will be coming up the Potomac."

House Ways and Means Committee Chairman Dan Rostenkowski (D-Ill.) said Reagan had invited the cutbacks in both defense and foreign aid, which was also slashed in both House and Senate budgets, by his refusal to compromise on taxes. "The president must realize he will not get his way on defense and foreign aid without participating in a balanced approach that includes revenues," Rostenkowski said.