First, I will explain what tests DO tell you the bacteria, and how they are used. Secondly, I will explain why clinicians rarely do that for respiratory infections.
To test for bacteria, a sample can be taken of the body tissue/fluid that is infected - blood for bacteremia, urine for bladder/kidney infection, pus for abscess, spinal fluid for meningitis, sputum for respiratory infection, etc.
Usually, soon after taking the sample, treatment is started with "broad spectrum antibiotics," rather than waiting for test results while the infection grows. This is called "Empiric Therapy." Then, when results come back, the antibiotic choice can be "narrowed" in to target the likely bacteria.
Gram Stain can give a hint to the bacteria type, which is sometimes enough to assume what it is.
Bacterial cultures not only tell you the specific bacteria (usually), it can test for which exact antibiotics kill it the best. That is called antibiotic sensitivities.
Commonly, the first test to come back is the Gram Stain, which can be minutes to hours. For example, "gram positive cocci" highly suggests Staphylococcus or Streptococcus. In this case, we could narrow the antibiotic spectrum to something that kills those types of bacteria.
Then, 24-72 hours later is usually the earliest that culture results are available. For example, it would tell us (1) Staphylococcus aureus and (2) Resistant to Methicillin but Sensitive to Vancomycin, Clindamycin... (other representative antibiotics). That would define this bacteria as Methicillin-Resistant Staph Aureus (MRSA). Then we could further narrow the antibiotic to Vancomycin, Clindamycin, etc depending on what kind of infection it is and a bunch of other factors.
The respiratory tract (including your mouth) is colonized with many different kinds of bacteria. The bacteria in the phlegm from your lungs will show up in a gram stain or culture, but so will a lot of the bacteria from your mouth. How then would you know which is causing the infection?
Instead, usually, a clinician will go straight to prescribing an antibiotic that kills the most common bacteria that cause your specific signs/symptoms. Empiric therapy. Then if it doesn't work, they may investigate further.
Clinicians often take cultures for (1) serious infections like blood infections (2) suspected uncommon or dangerous pathogens (like tuberculosis) that AREN'T oral colonization bacteria or (3) sometimes after a common antibiotic has failed.