A practical and eco-friendly method for the controllable aerobic oxygenation of sulfides by electrochemical catalysis was developed. The switchable preparation of sulfoxides and sulfones was effectively controlled by reaction time, in which both molecular oxygen and water can be used as the oxygen source under catalyst and external oxidant-free conditions. The electrochemical protocol features a broad substrate scope and excellent site selectivity and is successfully applied to the modification of some sulfide-containing pharmaceuticals and their derivatives.