Herein, CuBi2O4 microspheres were first deposited on TiO2 nanotube arrays to develop a p-n CuBi2O4/TiO2 heterojunction by a facile hydrothermal protocol. The variations in the photoinduced open-circuit potential, photocurrent, and electrochemical parameters of the nickel-plated magnesium alloy (Mg/Ni) demonstrated the remarkably strengthened photoelectrochemical efficiency and photocathodic protection (PCP) capability caused by the CuBi2O4 modification. This enhancement is attributed to establishing a built-in electric field and intensified light absorption in a broadened wavelength spectrum, confirmed by the valence band XPS and ultraviolet-visible spectra. The as-prepared photoanode showed an unprecedentedly high photocurrent density compared with that of current heterojunctions based on CuBi2O4 and TiO2 semiconductors. The heterojunction continuously provided PCP to the Mg/Ni couple and suppressed the galvanic corrosion between the Mg and nickel-phosphorus alloy. This study proposed a new strategy for constructing a heterojunction with a novel morphology and considerably enhanced photoelectrochemical performance.