Fossil group origins. III. The relation between optical and X-ray luminosities