Controllable multipartite entanglement is a crucial element in quantum information processing. Here we present a scheme that generates switchable bipartite and genuine tripartite entanglement between microwave and optical photons via an optoelectromechanical interface, where microwave and optical cavities are coupled to a mechanical mode with controllable coupling constants. We show that by tuning an effective gauge phase between the coupling constants to the “sweet spots,” bipartite entanglement can be generated and switched between designated output photons. The bipartite entanglement is robust against the mechanical noise and the signal loss to the mechanical mode when the couplings are chosen to satisfy the impedance-matching condition. When the gauge phase is tuned away from the “sweet spots,” genuine tripartite entanglement can be generated and verified with homodyne measurement on the quadratures of the output fields. Our result can lead to the implementation of controllable and robust multipartite entanglement in hybrid quantum systems operated in distinctively different frequencies.