Several types of associative learning are dependent upon the presence or absence of food, and are crucial for the survival of most animals. Target of rapamycin (TOR), a kinase which exists as a component of two complexes, TOR complex 1 (TORC1) and TOR complex 2 (TORC2), is known to act as a nutrient sensor in numerous organisms. However, the in vivo roles of TOR signaling in the nervous system remain largely unclear, partly because its multifunctionality and requirement for survival make it difficult to investigate. Here, using pharmacological inhibitors and genetic analyses, we show that TORC1 and TORC2 contribute to associative learning between salt and food availability in the nematode Caenorhabditis elegans in a process called taste associative learning. Worms migrate to salt concentrations experienced previously during feeding, but they avoid salt concentrations experienced under starvation conditions. Administration of the TOR inhibitor rapamycin causes a behavioral defect after starvation conditioning. Worms lacking either RICT-1 or SINH-1, two TORC2 components, show defects in migration to high salt levels after learning under both fed and starved conditions. We also analyzed the behavioral phenotypes of mutants of the putative TORC1 substrate RSKS-1 (the C. elegans homolog of the mammalian S6 kinase S6K) and the putative TORC2 substrates SGK-1 and PKC-2 (homologs of the serum and glucocorticoid-induced kinase 1, SGK1, and protein kinase C-α, PKC-α, respectively) and found that neuronal RSKS-1 and PKC-2, as well as intestinal SGK-1, are involved in taste associative learning. Our findings shed light on the functions of TOR signaling in behavioral plasticity and provide insight into the mechanisms by which information sensed in the intestine affects the nervous system to modulate food-searching behaviors.