Animals have developed stereotyped communication calls to which specific sensory neurons are well tuned. These communication calls must be discriminated from environmental signals such as those produced by prey. Sensory systems might have evolved neural circuitry to encode both categories. In weakly electric fish, prey and communication signals differ in their spatial extent and frequency content. Here we show that stimuli of different spatial extents mimicking prey and communication signals cause a switch in the frequency tuning and spike-timing precision of electrosensory pyramidal neurons, resulting in the selective and optimal encoding of both stimulus categories. As in other sensory systems, pyramidal neurons respond only to stimuli located within a restricted region of space known as the classical receptive field (CRF). In some systems, stimulation outside the CRF but within a non-classical receptive field (nCRF) can modulate the neural response to CRF stimulation even though nCRF stimulation alone fails to elicit responses. We show that pyramidal neurons possess a nCRF and that it can modulate the response to CRF stimuli to induce this neurobiological switch in frequency tuning.