It was the end of a long hearing, and Republican Sen. Lowell P. Weicker Jr. was lecturing the secretary of education because of his controversial remarks about some college students spending their federal aid on stereos and beach vacations.

"I said up in Connecticut that I would get even with your statements by increasing your budget," Weicker told Secretary William J. Bennett.

It is one of the accidents of history that this doggedly liberal senator from Connecticut is in a position to make good on his threat.

For years it was conservatives who sat astride key committees in Congress, blocking liberal legislation and frustrating presidents. Now, just when the conservative movement is at its peak, an unpredictable fate has deposited Weicker on a strategic perch where he can help turn the tide.

When one of his Republican colleagues was defeated in 1982, Weicker ascended to the chair of the Senate Appropriations subcommittee on Labor, Health and Human Services and Education. And the 15-member panel is determined to protect student aid, job training, health research and other domestic programs that President Reagan wants to trim or eliminate.

"As a practical matter, the Appropriations Committee is probably the last bastion of moderate political philosophy in the Senate," Weicker said. "It's a very difficult forum in which to practice Reaganomics."

Weicker charges that administration officials "are trying to beat up on the frailest elements of our society . . . . I'm not in a budget-cutting exercise here. I think education, health, the handicapped and mentally retarded are important. And I've prevailed rather well."

But while the appropriations chairmen once reigned supreme, Weicker may find himself steamrollered by the budget contraption that Congress assembled a decade ago. The Senate Budget Committee is trying to preempt the 13 appropriations subcommittees this year with an extremely detailed deficit-reduction plan. The plan, backed by the Republican leadership, would abolish the Job Corps, reduce student loans and sharply cut other programs that have fared well during Weicker's stewardship.

If the budget plan holds up, one subcommittee official said, "It will gut our jurisdiction. If the Budget Committee can say 'no more Job Corps,' why have an Appropriations Committee? Why have any of these other committees?"

But many officials expect the fragile budget compromise to collapse. Others point out that the appropriations panels routinely have circumvented past budget ceilings through supplemental spending bills and other devices.

"We maneuver around the budget limits and sometimes ignore them," said Sen. William Proxmire (D-Wis.), the panel's ranking Democrat and in-house fiscal conservative. "We've consistently gone above the president's recommendations in the subcommittee year after year, on education and health, by substantial margins.

"We have to find a way to say no to some very good programs," Proxmire said. . . . "These subcommittees tend to become champions of their clientele. Year after year, we've had huge increases in the National Cancer Institute because it's such a horrible disease and everyone has a friend or relative who has cancer. It's an easy pitch. If you don't support it, it looks like you're voting for cancer."

Weicker and Proxmire are a sort of political odd couple: the Republican speaks eloquently of the plight of the poor and elderly, while the Democrat lectures about fiscal responsibility. Weicker often kids Proxmire about being Reagan's agent on the subcommittee.

But Weicker enjoys a clear working majority, in part because senators who seek membership on the subcommittee tend to be strong defenders of its programs. So while Proxmire supports the administration's effort to abolish the Job Corps, he concedes he doesn't have enough support to kill it.

"When push comes to shove, even the conservatives vote for things like the Job Corps," one staff member said.

Because it covers so many social programs, the spending legislation the subcommittee produces has long been a partisan battleground. Presidents Richard M. Nixon and Gerald R. Ford each vetoed the bill twice because it exceeded their requests by about $1 billion, a paltry sum by today's standards.

Former senator Warren G. Magnuson (D-Wash.), who chaired the panel during the 1970s, made sure each budget took care of the home folks; the University of Washington's health center is one of several buildings that bear his name. Magnuson's successor, former senator Harrison H. Schmitt (R-N.M.), tried in vain to stop colleagues from adding their home-state projects on the Senate floor.

Weicker has fended off many of these "add-ons" since becoming chairman in 1983, but he also has boosted spending in most of the major programs. And by working with House Democrats, he has succeeded in having the last two spending bills signed into law -- no small feat at a time when many agencies are forced to operate year-round on stopgap continuing resolutions.

Weicker said he works his will "by teaming up with the Democrats . . . . My chairmanship is in tune with the Democrats, and enough Republicans, so the bills can pass on the Senate floor."

Weicker's moderate allies on the panel include Mark O. Hatfield (R-Ore.), chairman of the full Appropriations Committee, as well as Arlen Specter (R-Pa.) and Mark Andrews (R-N.D.). The Democratic side includes Minority Leader Robert C. Byrd (D-W.Va.), Ernest F. Hollings (D-S.C.), Thomas F. Eagleton (D-Mo.), Lawton Chiles (D-Fla.), Quentin Burdick (D-N.D.) and Daniel K. Inouye (D-Hawaii).

Weicker's agenda isn't hard to decipher. At hearing after hearing, he has accused the administration of focusing its cuts on the poor and disadvantaged and explaining them away with misleading statistics. He frequently invokes the specter of Budget Director David A. Stockman as the man behind the cuts.

In recent weeks, Weicker has:

* Charged laxity in inspecting homes for the mentally retarded. "The almighty God of this administration is how to save a buck," he declared. "And we aren't going to save any bucks at the expense of the mentally retarded and handicapped. Not when I'm the guy that receives their budgets."

* Castigated Bennett for saying the country didn't really need a department of education. Weicker also criticized Bennett for arguing that needy students will receive a greater proportion of Pell grants, although the administration wants to cut that program so deeply that their aid would shrink by $240 million. "Don't you think that's sort of misleading?" he asked.

* Forced the resignations of a Bennett deputy who had questioned the need for aid to the handicapped and an aide who favored abolishing the National Institute of Education.

* Admonished Health and Human Services Secretary Margaret M. Heckler for planning three research centers for Alzheimer's disease when Congress approved five: "When you have people suffering from Alzheimer's disease, don't try to balance the budget on them."

* Accused acting Labor Secretary Ford B. Ford of using phony figures to justify Reagan's plan to abolish the Job Corps. He said the Labor Department was presenting higher figures on the cost of training disadvantaged youths and lower figures on the program's success rate than it did in testimony last year.

"Now, in order to fit ourselves into the president's and Mr. Stockman's philosophy, we're using different figures," Weicker told Ford. . . . "You're talking about youngsters that come from a background of broken homes and alcoholism and drugs and the rest. It's the toughest universe to deal with."

* Asked whether a plan to cut the Social Security Administration's staff by 17,000 originated with Stockman's office. Weicker said he would not accept any plan based on "whether David Stockman has to get X amount of dollars out of the Social Security Administration so he can give it to the Defense Department."

* Scolded the National Institutes of Health for trying to reduce the number of grants it awards each year from 6,500 to 5,000, and got the General Accounting Office to rule the practice improper. "Anybody that does go ahead and disburse these funds improperly does so at their personal risk," Weicker warned NIH officials. "That means your house, your car, not the government's."

But the NIH dispute also underscores the limits of the subcommittee's power when agencies decide to interpret legislative language on their own. The NIH says it is not bound by the panel's language on the number of grants, the subcommittee insists that it is, and they may spend months fighting it out.

Weicker said he is forced into this sort of micro-management because the administration keeps trying to find ways to avoid spending money appropriated by Congress.

"We're only made to look irresponsible on spending by virtue of what the administration is doing," he said. "These budgets have all been trimmed time and again and the programs tightened up. I could easily add 10 or 15 percent to these major programs and I still wouldn't be meeting the real needs."