A three-judge federal panel ordered the state of Virginia yesterday to provide private schooling for all handicapped children when necessary and ruled unconstitutional a law that required the state to take custody of indigent handicapped children needing special private education.

The panel, which issued its decision in Richmond, ruled that a state law requiring parents to relinquish custody of their handicapped children to the state when they are unable to pay for private special education "is violative of the right to family integrity."

The ruling came in a class action suit filed on behalf of two youths from Fairfax County and one from Henrico County.

The order said the state is obligated to "provide appropriate private education to (all poor handicapped students) commensurate with the education available to the more affluent handicapped children . . . for so long as no appropriate public education is available to them."

The three judges, John D. Butzner Jr., Robert R. Merhige and D. Dortch Warriner, gave the state 30 days to devise a plan to provide special education for all of the state's handicapped children, estimated to number between 25,000 and 36,0000.

Under the ruling, the state must either improve the public education system to include more and better special education programs for handicapped students or pay their full tuition to private schools. State officials do not know how the decision will affect them, according to Assistant Attorney General Walter H. Ryland said. "The effect on the state can't be asessed right now. On the first day an opinion is handed down there's not much that's certain."

"I think it's great," said Stephen W. Bricker an American Civil Liberties Union attorney who represented the handicapped youths. "As a practical afford to neglect public special education like it has done in the past.

"The state can sit back on its hands and not worry about public education if it wants to, but it will cost it a lot of money," Bricker said.

Under Virginia law, children who live at home and require special education outside of regular public school because of their needs or limitations of a school system are given partial tuition grants by the state to attend private schools.

Parents are then required to make up the substantial differences between the State and local government grants and the actual costs of the private schooling. To receive full funding, parents who cannot afford to pay the full amount must relinquish custody of their children who then are sent to state facilities.

Partial grants can be as high as $1,250 a year for nonresidential schooling programs and $5,000 for residential programs.

According to a Fairfax Legal Aid spokesman, the average cost of non-residential private programs in Virginia last year was $3,515, while the cost of residential special education average $10,345. On the average parents would have to make up differences ranging from $2,263 to $5,345 a year, the spokesman said.

The ruling affects all handicapped children, including sight, hearing impaired, physically disabled children and youths who are learning disabled, mentally retarded or emotionally disturbed.

The ruling also requires that all handicapped youths in the state's custody in order to receive special education must be returned to their parents or guardians within 60 days.