Can you tell me if a tooth infection has spread to lungs then what is the treatment, extraction?

SERIOUS! I hope this hasn't happened to you and it just reinforces the importance of not letting dental or medical problems go untreated. Have your physician treat you medically and for the lung infection and have your dentist discuss your options regarding all your dental needs. Lesson learned.
Possibly. If an infection from a tooth spread to your lungs, it was a pretty serious infection. The decision to save or extract the tooth should be made by the medical team treating you. No reason to risk your health if the tooth is questionable.