The “default” LTspice transistor is idealized. Real ones aren’t that good :)
Bipolar transistors are called “switches” but they are not literal switches like a toggle switch is – they are not mechanical contacts.
Perhaps inadvertently, you have set up the transistor as a common-base switch, and that has a chance of working acceptably – you just need some load, the output can’t float.
simulate this circuit – Schematic created using CircuitLab
The component values do depend on the parameters of the transistor, and have to be adjusted in practice. It's not the best way to implement a switch, but it certainly works well enough to be useful for something.
The general idea for common-base switches is having ample amplitude of base drive. Ideally, the base drive would be a current source.
Below are the input, output and control waveforms of the circuit above. The control waveform's amplitude is scaled down 50% to make it fit better in the plot.
The non-linear distortion is about 0.5%. The input, output and distortion residue waveforms are plotted below.
The output isolation at 1kHz in the off state is beyond the fidelity of CircuitLab, presumably better than -70dB - this can depend a lot on the transistor used as well.
Another way to achieve a switching action would be to short a high-impedance source.
For example:
simulate this circuit
The output swings to 0V when it's turned off:
The isolation when OFF is about -66dB, or about 1-in-2000.
A more dependable way to implement a bipolar switch would be to convert the input signal to a current, then switch the current between two resistors, and take the output from one resistor only.
simulate this circuit
The switching action is clean:
The distortion residuals are <0.1%:
A practical realization of the switch circuit requires a voltage-current converter (V->I), and a source of bias currents, shown below.
simulate this circuit
The various currents are derived from a 100uA reference. The current mirror used is an improved 4-transistor Wilson mirror. The additional transistor buffers the base currents and allows paralleling of multiple current output stages in one mirror.
An LM334 could generate the reference cut rent. Another option would be REF200, but it costs an order of magnitude more.
The V->I converter uses a unipolar output op-amp to maintain 3V at the emitter of Q23. R8 loads the input voltage using 3V as the reference, converting it into current. The current passes through Q23.
Perhaps there could be a cascode transistor behind Q23 to increase the accuracy without slowing down the response, but at 5V there’s not much voltage drop to work with – it’d need to be an inverted cascode.
Q23 and the cascode, if any, would benefit from base current compensation, to improve gain accuracy. Q23 could also be a high transconductance low voltage mosfet.
The current then gets subtracted from the 300uA reference, and enters the Q1-Q2 current steering pair. When the switch is turned on, Q2 conducts and passes the current through the output load resistor R5. The current steering could also be done by mosfets, bringing the gain back to 1.000 if combined with a mosfet Q23.
The voltage gain of the switch is about 0.983. Both the input and output impedance are 10 kOhm.
The switching action waveforms are below.
Distortion is under 0.1%. As shown below, it is about 0.06% at 1kHz.
OFF isolation at 1kHz is -90dB according to CircuitLab. In practice I'd expect -80dB at least with careful layout.
Given the relatively high output impedance, the output would need a buffer stage.
Lower distortion can be achieved by running the switch at a lower gain, say 0.2, and having the buffer stage add the gain back.
The V->I converter could be done with an op-amp Howland current pump, but that would take good resistors and a good op-amp to be better than the discrete circuit. At 30kHz, you'd need an op-amp with GBW to 10MHz to maintain reasonable distortion, if you care about that.
An op-amp could provide the gain and buffering of the switch output, of course.
Getting a transistor acting as a good switch takes a bit of work by the surrounding circuitry :)