Dr. Philip Handler, 64, a retired president of the National Academy of Sciences, a biochemist noted for his work on nutrition and an advocate for human rights as well as scientific freedom, died yesterday at New England Deaconess Hospital in Boston. The cause of his death was cancer complicated by pneumonia.

Dr. Handler became the 18th president of the National Academy in 1969. He retired last June, having served the statutory limit of 12 years. The academy is a private organization chartered by Congress as the principal adviser to the government on scientific and technical questions. It is made up of more than 1,000 of the nation's most distinguished scientists.

By virtue of the academy's charter as well as his own inclinations and abilities, Dr. Handler had a marked influence on scientific policy in the United States.

During his tenure as president, the academy carried out hundreds of studies on questions ranging from the environment to foods and drugs to genetic engineering. To facilitate this process, Dr. Handler reorganized the National Research Council, the operating arm of the National Academy of Sciences and the National Academy of Engineering. The reorganization enlarged the council's scope. It also ensured that the work would be conducted in accordance with accepted scientific norms and reviewed by competent authorities before being submitted to the government.

Apart from presenting--and sometimes defending--the academy's work before Congress and various government agencies, Dr. Handler spoke out on many other subjects, especially the relationship between scientific inquiry and human rights. He was a frequent critic of the Soviet Union, despite numerous ties the academy maintains with learned bodies in that country.

"We perceive no essential distinctions between pursuit of truth about the nature of man or of the physical universe and pursuit of truth about the human condition in the societies in which we live," he said in an address to the Scientific Forum of the Conference on Security and Cooperation in Europe in 1980. "We will speak out for those whose rights have been denied, for the cost of silence is the abandonment of human rights, and that is a price we will not pay."

At a dinner given by the academy on the occasion of his retirement, Dr. Handler said, "I have had an absolutely glorious time . . . Opportunities for service which are at the same time warm, loving, rich experiences are very rare. I have been very fortunate and deeply, highly privileged by all of you."

In October, President Reagan awarded Dr. Handler the National Medal of Science. The citation said it was for his "outstanding contributions to biomedical research, resulting in significant contributions to mankind, including research that led to a clearer understanding of pellagra, and for his national leadership in furthering the state of American science."

As a researcher, Dr. Handler made his mark for his work on the link between pellagra and vitamin B deficiencies. Up until World War II, pellagra was endemic in the South. The disease can cause sores in the mouth, gastrointestinal and nervous disorders, and death. Its primary cause was a diet made up mainly of pork and corn. By exploring the absence of niacin, a B vitamin, as a cause of pellagra, Dr. Handler and others contributed to the eradication of the disease as a public health problem.

This came about partly through improved nutrition--adding niacin, riboflavin, thiamin and iron to bread and cereals--and partly through the improved economic conditions, and the attendant improvement in diet, of the war.

Dr. Handler did his work at Duke University in Durham, N.C., where he went as a researcher in 1939. He later joined the faculty and in 1950 was named head of the department of biochemistry and nutrition of the Duke University medical school. In 1960, he was named a James B. Duke Distinguished Professor. He held these positions until he took the presidency of the National Academy of Sciences.

A native of New York City, Dr. Handler was educated at the City College of New York and the University of Illinois. He was the author of more than 200 papers published in professional journals and a coauthor of "Principles of Biochemisty," now in its sixth edition and a standard textbook at many medical schools here and abroad. He received 23 honorary degrees.

Survivors include his wife, Lucille, of Durham, N.C.; two sons, Mark, also of Durham, and Eric Paul, of Greensboro, N.C.; a brother, Melvin, of New York City, and two grandchildren.