Switching between GND and 10V VREF?
What you're looking for is called an analog multiplexer. The most common example is probably the classic CD4066. In general, multiplexers work as a group of FETs tied together at one end. For a 2-input mux, it would look something like







simulate this circuit &ndash; Schematic created using CircuitLab

A select line turns on one FET while turning off the other. Your original concept was OK in principle, but the saturation voltage of the transistor would have meant that the zero output would not be exactly zero.

Also note that this is a simplified circuit - a real multiplexer will use multiple FETs to allow a full range of inputs. See the 4066 data sheet for more details of how it's actually done.