Diet is proposed to affect brain aging. However, the causality and mechanism of dietary effects on brain aging are still unclear due to the long time scales of aging. The nematode Caenorhabditis elegans (C. elegans) has led aging research because of its short lifespan and easy genetic manipulation. When fed the standard laboratory diet, Escherichia coli (E. coli), C. elegans experiences an age-dependent decline in temperature-food associative learning, called thermotaxis. To address if diet ameliorates this decline, we screened 35 different lactic acid bacteria as alternative diets. We found that Lactobacilli in a clade enriched with heterofermentative bacteria ameliorated age-dependent decline. On the other hand, homofermentative Lactobacillus species did not show this beneficial effect. Lactobacilli affected the thermotaxis of aged animals through DAF-16, an ortholog of mammalian FOXO transcription factor, while the effect on the thermotaxis was independent of the lifespan and locomotion. Our results demonstrate that diet can impact brain aging without changing the lifespan and that bacterial screen using C. elegans is a powerful approach to investigate age-dependent behavioral decline.