Rep. Phil Gramm, the conservative Texas Democrat who lost his seat on the House Budget Committee for supporting President Reagan's economic programs, resigned from Congress today and said he would seek reelection as a Republican.

"I cannot in good conscience continue to work within a national party that seeks to limit my effectiveness on behalf of those I represent in its effort to perpetuate the spending spree which has crippled our nation, threatened our position of world leadership and robbed our workers and retirees," he told reporters at his district office here.

Gramm submitted his resignation to Texas Gov. Bill Clements (R) and House Speaker Thomas P. (Tip) O'Neill Jr. (D-Mass.), effective 6 p.m. EST today. Clements immediately set Feb. 12 for a special election.

There will be two other special elections for House seats this year. Benjamin S. Rosenthal (D-N.Y.) died of cancer Tuesday, and Rep.-elect John L. (Jack) Swigert (R-Colo.) died of cancer last week. Election dates for these have not been set.

"I recognize that my political future might, because of this action, go down in oblivion," Gramm said. "But in the final analysis I can only follow the course which in my heart and conscience I believe to be right. I do not know whether this is a wise decision, but I do believe that it is an honest one."

Rebutting criticism that he was perhaps needlessly forcing the people of the 6th Congressional District to pay for a special election, Gramm said he would pay for it himself if he is unopposed. He challenged potential opponents to share the cost with him.

Gramm said he had decided to quit the House and run again because "there are those who voted for me as a Democrat who would view it as wrong for me to walk across the aisle and change parties and serve out the remainder of my term as a Republican having been elected as a Democrat."

The last House member to resign during a term and seek reelection in another party was Democrat Albert Watson of South Carolina. He quit the House in February, 1965, after being stripped of his seniority for endorsing Sen. Barry Goldwater (R-Ariz.) for president in 1964 and was reelected as a Republican in June, 1965.

Gramm had been seeking a dramatic break with the Democratic Party ever since it became clear that he would be disciplined for his role in the 97th Congress. Today he appeared to have succeeded. The small office where he made his announcement was packed with television cameras and newspaper reporters.

The timing of the special election will work to Gramm's benefit, according to politicians from both parties. Gramm said he expected to be "out walking the streets" Monday asking people to reelect him as a Republican.

He begins the political fight with about $207,000 in leftover campaign funds, and said he would be "constrained" by the amount he could raise. "I have tried to run my elections the way I would like to run the government--that is, in the black with money in the bank," he said.

But the former economics professor at Texas A&M University and advocate of a leaner federal government did not say he would try to run a lean campaign. Last year he spent $800,000 winning reelection.

In letters to other House Democratics that Gramm wrote two years ago when he was lobbying for a seat on the Budget Committee he promised to vote for whatever budget came out of the committee. Gramm later was a leader in defeating the committee alternative in favor of Reagan's budget plan.

Release of the letters apparently was intended to embarrass Gramm, bitterly disliked by Democratic leaders who say he cannot be trusted.

"While I have strong views on the necessity of balancing the budget and opinions about how that goal should be achieved," Gramm wrote in a letter last January, "I intend to be a responsible member of the Budget Committee. I will work hard to perfect the budget in committee and during floor debate, but as a member of the committee I will support final passage of the budget.

Another letter, to Democratic Caucus Chairman Gillis W. Long of Louisiana, promised "to work diligently to assure that Democrats in the House are presented budget resolutions they can enthusiastically support on the floor and at home in their districts."

Long told reporters today that both parties would be better off with Gramm in the Republican Party, because "from day one, he caucused with Republicans and passed confidential information."

"It is the story of the fox in the hen house," Long said. "Now suppose Mr. Gramm was in the Dallas Cowboys huddle and he told the opposing team what play was being called. Do you think they'd invite him to huddle with them again?"

Meanwhile, Democrats scrambled to find a candidate to oppose Gramm in this traditionally Democratic district.

"We've got people who are strong in the southern end of the district or strong in the northern end," said one Democrat. "Nobody's strong in the whole district other than Gramm."