David Kennedy, the 24-year-old son of Robert F. Kennedy, has entered a Boston Hospital in serious condition for treatment of a heart infection that sometimes is associated with narcotics addiction.

The Kennedy family announced the hospitalization in its first statement since Kennedy told police last week that he was robbed of $30 in a Harlem hotel known to be frequented by drug pushers and addicts.

He was being treated at Massachusetts General Hospital for bacterial endocarditis, an infection of the lining of the heart and its valves, according to the statement released through the office of Robert Kennedy's brother-in-law, Stephen Smith.

The infection can be introduced in many ways, including through small breaks in the skin. One cause listed by the standard medical reference book, Mercks Manual of Diagnosis and Therapy, is "self-administration of narcotics intravenously."

The family statement made no mention of narcotics. It has been widely reported in New York newspapers and broadcasts since the Harlem incident that Kennedy has been fighting drug addiction for several years.

"After Wednesday's incident in New York," the statement said, "David voluntarily put himself in a hospital in Boston. He was suffering an extremely high fever which did not respond to ordinary treatment and it was felt necessary on Saturday to transfer him to the Massachusetts General Hospital. The transfer took place on Sunday."

Kennedy is being treated with antibiotics and his condition "is somewhat improved although still very serious" the statement added.

Kennedy's doctors estimate that he will be in the hospital several weeks. He had been treated in Massachusetts General twice before, once for pneumonia and once for a heart disorder.

David, the fourth child of Robert and Ethel Kennedy, dropped out of college and has been a frequent visitor to New York discotheques in recent months, often getting his picture on the gossip pages of New York papers.

Since the incident in Harlem's Shelton Plaza Hotel, his whereabouts and reported drug problems have been discussed at length in the media.

"The family has for a long time been much concerned about his condition and has endeavored and will continue to endeavor to help him in what is finally a long and hard personal as well as medical struggle," the statement said. "And it is the family's hope that people will understand David's need for privacy as he continues this difficult effort."