RICHMOND, FEB. 2 -- Virginia would become the second state to seek approval of the use of heroin for cancer patients suffering intractable pain under a bill that squeaked through a House committee today on a 9-to-8 vote.

Federal law would have to be changed before heroin could be dispensed to cancer patients in the state, but federal legislation is pending. State proponents said that an affirmative legislative result in Virginia would add impetus to the federal effort and save time in getting heroin to state patients if Congress approves.

"Sometimes we ought to take a chance" on legislative initiatives, commented Del. Robert Tata (R-Virginia Beach). "We could almost lead the entire country on this." New Jersey is the only state that has approved similar legislation, he said.

The Virginia bill would register doctors to dispense heroin to terminally ill cancer patients and develop procedures to determine what patients would receive the drug and to establish record-keeping and storage standards.

The House Health, Welfare and Institutions Committee split along unusual lines. "I have to admit that when I first saw this bill, my knee jerked up and I got the feeling that, here we go again, doing something stupid or liberal or something," said Del. S. Vance Wilkins Jr. (R-Amherst), who supported the measure. "Sympathy without action is pretty hollow," he added.

Other members of the panel worried that the bill would exacerbate illegal heroin use and said they did not have enough facts about where the heroin would be bought, who would have access to it and who would administer the program.

Those were among the arguments used in the U.S. House of Representatives when legislation to permit heroin use for cancer patients was defeated overwhelmingly in the fall of 1984.

A spokesman for the Virginia Medical Society said the group believes the legislation is premature and could not endorse it.

Del. Mary A. Marshall (D-Arlington), supporting the measure, predicted the bill could influence Congress to act on the issue.

Virginia endorsed the use of an ingredient of marijuana for certain medical uses, and this was approved by the federal government, she said.

Bills have been reintroduced in the U.S. House and Senate to authorize doctors to use heroin for dying cancer patients, but no action has been taken.