I guess the generic answer for any mass separation system would be that you spin it, but mass separation isn't really effective for electrolysis since that requires larger separation between anode and cathode which leads to protonic ohmic losses, i.e. increased internal resistance. So a more optimal species separation is done not by their mass but by their size and charge, usually through a Proton Exchange Membrane (PEM).
PEM electrolysis allows for tighter electrode placement to reduce ohmic losses, allows for higher current and is tolerant to relatively high pressures. Water if fed on the anode end, and as current flows from cathode towards the anode, water is separated into hydrogen and oxygen, positively charged hydrogen is attracted through PEM towards the negatively charged cathode, and the negatively charged oxygen is repelled away from cathode towards the positively charged anode:
Diagram of PEM electrolyzer cell and the basic principles of operation. Animation source: Wikipedia on PEM electrolysis
PEM electrolysis is also main source of oxygen on the International Space Station, and they use perchlorate candles as backups (for emergencies or when the electrolysis machine is not operational):
The generator operates on a simple principle — electrolysis, the
dissociation of oxygen and hydrogen from water through the application
of electricity. What makes the generator safe? The device uses a
proton-exchange membrane (PEM) to separate the generated hydrogen and
oxygen.
In a PEM electrolyzer, water is oxidized at the oxygen electrode, or
cell anode, to produce oxygen gas, releasing hydrogen ions (protons)
and electrons. The hydrogen ions migrate from the cell anode to the
cell cathode, or hydrogen electrode, under the effect of the electric
field imposed across the cell, while the electrons are transferred by
a dc power source. The protons and electrons recombine at the cell
cathode to produce hydrogen. Liquid water is also released at the
cathode due to a process called electro-osmotic drag. Oxygen and
hydrogen are generated in a stoichiometric ratio—two volume units of
hydrogen for every one of oxygen—at a rate proportional to the applied
cell current.