Bit-error detection and correction is a very important part of a data communication network. In this article, we propose an optical approach to designing an error detection and correction circuit using Hamming code-based frequency encoded binary data and Toffoli gates.Here, the Toffoli gates are made of semiconductor optical amplifiers (SOAs) that work based on the nonlinear polarization rotation property. The characteristics of SOA, including very fast switching action (about 0.01 ns), low power consumption, frequency independent crosspolarization gain in the C-band, cascading property, etc., make the scheme attractive. The frequency encoded data-based proposed scheme will be effective for WDM communication networks. MATLAB simulation results testify to the feasibility of the proposed scheme.