We present time-resolved broad-band observations of the quasar 3C 279 obtained from multi-wavelength campaigns conducted during the first two years of the Fermi Gamma-ray Space Telescope mission. While investigating the previously reported gamma-ray/optical flare accompanied by a change in optical polarization, we found that the optical emission appears delayed with respect to the gamma-ray emission by about 10 days. X-ray observations reveal a pair of `isolated flares separated by ~90 days, with only weak gamma-ray/optical counterparts. The spectral structure measured by Spitzer reveals a synchrotron component peaking in the mid-infrared band with a sharp break at the far-infrared band during the gamma-ray flare, while the peak appears in the mm/sub-mm band in the low state. Selected spectral energy distributions are fitted with leptonic models including Comptonization of external radiation produced in a dusty torus or the broad-line region. Adopting the interpretation of the polarization swing involving propagation of the emitting region along a curved trajectory, we can explain the evolution of the broad-band spectra during the gamma-ray flaring event by a shift of its location from ~ 1 pc to ~ 4 pc from the central black hole. On the other hand, if the gamma-ray flare is generated instead at sub-pc distance from the central black hole, the far-infrared break can be explained by synchrotron self-absorption. We also model the low spectral state, dominated by the mm/sub-mm peaking synchrotron component, and suggest that the corresponding inverse-Compton component explains the steady X-ray emission.