A private health care foundation is offering $17.2 million to 21 U.S. cities with large numbers of AIDS cases, including Washington and Baltimore, to give medical care and social services to people with acquired immune deficiency syndrome.

The cities would have to apply for the grants from the Robert Wood Johnson Foundation of Princeton, N.J.

The funds offered by the foundation are the largest private donation aimed at helping victims of the disease, which President Reagan recently described as the nation's No. 1 health priority.

Ten of the 21 eligible cities will receive the four-year grants, which are aimed at unifying AIDS efforts among city hospitals, public health departments, home health care agencies, gay advocacy groups and mayors' offices.

The grants also are aimed at reducing the cost of AIDS.

The cost of care for the first 10,000 of the nation's 17,001 AIDS cases is estimated at $1.4 billion.

Drew Altman, a vice president of the foundation, said cities are encouraged to emulate San Francisco's home-care programs that have reduced the average cost of hospital care in that city to $29,000 per AIDS patient. Nationwide, the average hospital bill for an AIDS patient is $140,000, nearly five times greater.

"San Francisco has broken the golden rule of health care costs, that new and better services always cost more," Altman said, citing the city's successful AIDS "buddy" programs and home health care services. "There it costs less."