A lung biopsy is done to: 1  Diagnose certain lung conditions, such as sarcoidosis or pulmonary fibrosis. 2  In rare cases, a lung biopsy may be done for severe pneumonia, especially if the diagnosis is not clear. 3  Diagnose suspected lung cancer.