How is a sputum culture obtained when you are being tested?

You spit it out. Basically, you hock up a logey and spit it into a sterile cup. If you can't hock up any phlegm, for whatever reason, they go in after it with a thin tube and suck it out.