President Reagan last night said he was giving serious consideration to a nickel-a-gallon gasoline tax increase next year to finance the rebuilding of the nation's deteriorating roads and bridges. He also opened the door to consideration of possible cuts in the defense budget.

In his first nationally televised news conference since the Nov. 2 midterm election, the president signaled flexibility on the sensitive issues of taxes and military spending at a time when pressure is mounting in Congress for changes by the administration on both points.

Reagan said he had not reached any final decisions.

But he cast the road and bridge repair program in a favorable light and a White House official said after the news conference that the president is leaning in favor of it.

As presented to Reagan earlier this week by Transportation Secretary Drew Lewis, the 5-cent-a-gallon gas tax boost would generate $5.5 billion a year to be dedicated to roads, bridges and mass transit. Although it is viewed primarily as a transportation initiative, administration officials estimate it would also produce 320,000 jobs at a time when Congress is demanding action to alleviate the highest unemployment rate since 1940.

"I don't view this proposal as, let's say, a job-creating program," the president said. "Although, obviously, there would be jobs created by going forward with that effort."

While the president said at his Sept. 28 news conference that it would take a "palace coup" to win his approval for new taxes next year, last night he made it clear that his objections did not include the gasoline tax increase. He called it a "user fee" instead of a tax and said it would not "in any way" interfere with the tax cuts he won from Congress last year.

Reagan had deferred action on the rebuilding program earlier this year. But he said it is now "under consultation and deep thought by all of us" and described the problem of crumbling roads and bridges as one that "must be met sooner or later."

Following the election, Democrats and Republicans on Capitol Hill said they viewed the returns as a signal that the nation wanted some response from Washington to the rising jobless rate.

While the road- and bridge-fixing program enjoys growing support in Congress, Reagan stopped short of endorsing an explicit public-works employment effort of the kind Democrats are readying for the lame-duck session of Congress that begins Nov. 29.

"It is true that there are other voices that are being raised in the Congress who are suggesting that the answer is to go back to things that have been tried in previous recessions, namely make-work job programs with the government taking billions of dollars out of the private sector to spend on these projects," Reagan said.

He claimed that $66 billion invested in public-works employment over seven years, ending in 1981, "got us nothing but an increase in unemployment. It did not resolve the problem."

Taking note of the Democratic proposals being floated on Capitol Hill, Reagan said he wouldn't accept any jobs program from Congress that "would be a drag on the economy and would slow down our effort to really restore legitimate employment.

"We're not going to go down the dead-end street that just leaves us set up for another recession," the president said. He pointed out that 3 million of the nation's 11.6 million unemployed are new entrants into the job market who have been unable to find work "because of the stagnant economy."

"And this has got to be one of our greatest problems--is creating the jobs to keep up with that kind of expansion," Reagan said. He failed to mention, however, that his 1980 campaign was built on a promise -- still unfulfilled -- to end that economic stagnation and create jobs.

Reagan acknowledged that unemployment was a volatile indicator of the nation's economic health and that it may rise still further before any relief is in sight. But he called attention to signals that the recession is ending, including a rise in sales of autos and new homes.

On military spending, the president was asked whether he agreed with those Republicans, as well as Democrats, who have called for some restraint in the proposed $1.6 trillion, five-year defense buildup Reagan has outlined. These demands for restraint have intensified since the election, whose results have been interpreted by some in both parties as a signal that American voters want a shift away from the military and toward jobs and domestic spending.

The president said the Pentagon budget couldn't be trimmed "for just one year" because of the long lead time of weapons systems, and he noted that a large portion of defense spending "is for humanity . . . for the men and women in the armed forces, the pay scale that is now approaching some reasonable level.

"But we're looking at everything," Reagan said of the defense budget. "I would have to say that yes, we're looking, if there are savings that can be made without delaying or setting back what we think is the improvement we must have if we're going to close that window of vulnerability that we inherited. . . .

"The first and primary function of the federal government is the national security."

When a reporter offered Reagan a list of troubled weapons projects, the president didn't hesitate to reaffirm his "faith in our technology" and attributed the problems to "bugs that have to be worked out" in any new project.

White House spokesman Larry Speakes said after the news conference that Reagan "hasn't changed the thrust of his commitment" to 7 percent annual growth in the Pentagon budget after inflation. Reagan "was talking mostly about management savings," Speakes said.

At his 14th nationally broadcast news conference since taking office, Reagan was confident and self-assured. His answers appeared unmarred by controversial misstatements of fact such as cropped up in earlier sessions. But he did respond sharply when asked to prove his earlier accusations that foreign nations had influenced the nuclear freeze movement.

There is "plenty of evidence" to support his claim, Reagan said. While the majority of those supporting the nuclear freeze are "sincere and well-intentioned," Reagan said the Soviet Union "saw an advantage in a peace movement" that would freeze armaments while the Soviets are far ahead in nuclear weapons.

But the president revealed none of the evidence he said existed, claiming that to do so would disclose intelligence information.

Reagan opened the news conference in the East Room with a statement underscoring his desire to work with the Soviets and hailing the space shuttle mission as one that would lead toward "peaceful exploration of the universe." Earlier in the day he talked by telephone with the four astronauts and joked, "Well now, wait till I get my hat and I'll go with you."

Discussing other topics last night, Reagan said:

The United States has made "sizable progress" in negotiations with its allies on a broad agreement to restrict East-West trade.

While Reagan said he had "nothing to announce" specifically, he talked about separating the trade agreement from the sanctions he imposed against the use of high technology for the Soviet natural gas pipeline. Such a separation is precisely what the allies hope will emerge from the talks.

"Our decision on the sanctions will be based on when we feel they have served their purpose, and when we feel that there could be a better situation without them," he said.

He does not believe there is "very much more room" to increase Social Security payroll taxes to bail out the financially troubled pension system. He offered no specific solution but said he understood why Sen. Robert J. Dole (R-Kan.) called for Democrats to take the lead in offering such solutions.