The role of the foraging (for) gene, which encodes a cyclic guanosine-3,5-monophosphate (cGMP)-dependent protein kinase (PKG), in food-search behavior in Drosophila has been intensively studied. However, its functions in other complex behaviors have not been well-characterized. Here, we show experimentally in Drosophila that the for gene is required in the operant visual learning paradigm. Visual pattern memory was normal in a natural variant rover (for R ) but was impaired in another natural variant sitter (for S ), which has a lower PKG level. Memory defects in for S flies could be rescued by either constitutive or adult-limited expression of for in the fan-shaped body. Interestingly, we showed that such rescue also occurred when for was expressed in the ellipsoid body. Additionally, expression of for in the fifth layer of the fan-shaped body restored sufficient memory for the pattern parameter "elevation" but not for "contour orientation," whereas expression of for in the ellipsoid body restored sufficient memory for both parameters. Our study defines a Drosophila model for further understanding the role of cGMP-PKG signaling in associative learning/memory and the neural circuit underlying this for-dependent visual pattern memory.