President Reagan yesterday endorsed a 5-cent-a-gallon increase in the federal gasoline tax previously backed by congressional leaders of both parties. He called the excise tax increase "a necessity" to preserve and rebuild deteriorating highways, bridges and urban transit systems.

At the same time the president said he is also still considering what would amount to a tax cut next year. Aides have proposed as a stimulus to the economy a speed-up of the 10 percent income tax cut already scheduled to take effect July 1. White House officials said Reagan will probably come out in favor of such a speed-up before he leaves for South America next Tuesday.

Minutes before he flew off to his California ranch where he will rest until Monday, the president called for enactment of the highway tax and repair legislation, which its sponsor, Transportation Secretary Drew Lewis, claimed would create 320,000 jobs. However, Reagan said he was acting to meet the needs of the highway system, not to reduce unemployment; he has been critical in recent months of jobs bills, most of which have been proposed by Democrats.

" . . . Obviously there will be some employment with it, but it is not a jobs bill as such," Reagan declared in a brief statement in the White House briefing room. "It is a necessity. It's a problem we have to meet, and we'd be doing this if there was no recession at all."

And last week, in fact, the chairman of the president's Council of Economic Advisers, Martin S. Feldstein, warned that the 5-cent increase on gasoline, which Reagan said would cost the typical motorist $30 a year, "may actually increase unemployment during the first year or two." That is because, while increasing jobs on highways, it would reduce jobs in consumer goods industries; consumers would have $5 billion less to spend next year because of the increased tax, Feldstein pointed out.

The gasoline tax is now 4 cents a gallon.

The president had been expected to announce support for the increase, but not until next Tuesday before departing on a five-day trip to Latin America.

But indications from both parties that Congress will pass the bill in the lame-duck session beginning next Monday convinced the White House that Reagan could not afford to wait.

"If we had waited, the train would have left the station," said a White House official yesterday.

On the income tax speed-up, White House officials said what is likely to happen is that Reagan will meet with Republican congressional leaders Tuesday morning before he departs for Brazil and then announce his decision. One official said that the president wants to consult with the GOP leaders "but will not necessarily be governed by what they say." Leaders of both parties have indicated they oppose a speed-up, on grounds it would widen the deficit. Whatever Reagan decides, administration officials acknowledge that the chances of passing an accelerated tax reduction in the lame-duck session are remote.

At a breakfast session with reporters yesterday, Secretary of the Treasury Donald T. Regan suggested that one alternative would be to reduce withholding rates by 5 percent on Jan. 1 to bring forward some of the stimulus of the tax cut. This would leave the deficit in 1983 as a whole unchanged as it would amount to a 5 percent cut in taxes over 12 months instead of a 10 percent cut for six months.

Under this proposal taxes would still be cut another 5 percent as scheduled in January, 1984.

But this idea disappeared almost as soon as it surfaced. White House officials said later in the day that Reagan still preferred a 10 percent tax cut effective Jan. 1 and Treasury officials told reporters that Regan also still favored this approach. Aides said Reagan may also propose other steps to stimulate the economy, but they would not elaborate.

The gas tax proposal that Reagan backed yesterday has been pushed by Lewis since last May. There was considerable support for it within the administration when a $98.9 billion tax measure was passed last August with bipartisan support.

Lewis said yesterday that the president decided at the time that the gasoline tax increase "would fuzz up the tax bill" and told him that he would look favorably upon it as a separate measure next year. But a desire among congressional leaders for both a jobs program and highway repair has increased pressure for the bill both at the White House and on Capitol Hill.

The measure, which would virtually assure an increase in gasoline prices next year, would raise $27.5 billion over a five-year period. One-fifth of the total would be earmarked for urban mass transit programs.

"An estimated 10 percent of our interstate highway system . . . portions of which are more than 20 years old . . . need immediate highway resurfacing," Reagan said in announcing his support for the plan. "We have 23,000 bridges in need of replacement or rehabiliation; 40 percent of our bridges are over 40 years old. Moreover, our cities face capital transit costs of some $50 billion as many buses and urban rail cars need to be replace or upgraded.

"Our country's outstanding highway system was built on the user fee principle . . . that those who benefit from a use should share in its cost," Reagan continued.

However, Reagan this time referred frankly to the "user fee" as a "tax." He maintained that this was not in violation of a statement he made at his Sept. 28 news conference when he said it would take "a palace coup" to cause him to raise taxes.

Reagan contended that his meaning at the time was that he wouldn't use highway taxes or excise taxes "as a source just for general revenue." He was whisked outside by aides and aboard his helicopter before he could be asked further questions and the briefing was turned over to Lewis.