Optimal channel switching and detector design is studied for M-ary communication systems in the presence of stochastic signaling, which facilitates randomization of signal values transmitted for each information symbol. Considering the presence of multiple additive noise channels (which can have non-Gaussian distributions in general) between a transmitter and a receiver, the joint optimization of the channel switching (timesharing) strategy, stochastic signals, and detectors is performed in order to achieve the minimum average probability of error. It is proved that the optimal solution to this problem corresponds to either (i) switching between at most two channels with deterministic signaling over each channel, or (ii) time-sharing between at most two different signals over a single channel (i.e., stochastic signaling over a single channel). For both cases, the optimal solutions are shown to employ corresponding maximum a posteriori probability (MAP) detectors at the receiver. Numerical results are presented to investigate the proposed approach.