Secretary of Health, Education and Welfare Joseph A. Califano Jr. has his eye on what may amount to $500 million a year that he thinks ought to be going to help the hard-pressed Social Security system, but to get it he is going to have to wrestle it away from the states and their congressional allies.

State and local governments have 9 million employes enrolled in the system, and they collect nearly $12 billion a year in Social Security payroll taxes that they eventually turn over to HEW.

But while they take the payroll taxes from workers every week or two they only have to turn it over to the federal government only every three months - unlike any large private employer who must do so weekly or biweekly.

So the state and local governments hold the money and plunk it into short-term federal government notes or banks where it draws interest, Senate sources said about 80 percent of them do this. Other communities use the money for their own purposes temporarily and avoid having to borrow money for short-term needs.

It is estimated that millions of dollars in "windwall" interest payments are received by the local and state governments from these investments, according to Senate staff aides.

Califano and the Social Security Administration, hungry for every buck they can find to help pay rising Social Security benefits loads, think the interest should rightfully go to the federal government.

If Social Security received the money every month from state and local governments instead of every three months HEW experts estimate, the Social Administration would be able to investiat in U.S. government bonds at around 7 percent and get $260 million itself in 1981. By 1985, it is estimated the Social Security trust funds would be getting $285 million a year from this interest. This money would than be used to help pay for benefits.

Social Security officials argue that even if the states were forced to turn over the payroll taxes monthly, this would still be far less frequently than any large private employer.

This proposal has brought a storm of protest from municipal, county and state government. HEW has received more than 800 yetters. The National Governors' Association has come out strongly against the idea. "Not only would states and local government units lose the interest, but they would be subjected to extraordinary new administrative burden," said a spokesman.

Senate Majority Leader Robert C. Byrd (D-W.Va.) and Social Security subcommittee chairman Gaylord Nelson (D-Wis.), are preparing a mesage warning Califano to keep his hands off the money and to withdraw a proposed regulation forcing the states to pay up each month.

They are circulating a round-robin letter already signed by 18 senators telling Califano of their opposition to his plans. Byrd has introduced legislation forbidding HEW to change the cellection schedule. A similar amendment may be offered to the tax bill in the House.

The issue has come up a few times in the past and HEW has always lost. In fact, an existing law pushed through by Byrd some time back specifies that even if Califano gets his new regulation, it won't go into effect for 18 months so that Congress will have time to reverse it if it wishes.

Califano is sticking to his position so far, despite the uproar. Social Security wants that interest money and it wants it badly. But so do the state and local governments.