If endocarditis has damaged the inner lining of your heart causing it to be unable to pump blood well, surgery is needed to correct the damage. Artificial valves that may have been made loose by the infection may also need to be replaced. Some infections caused by fungi could also be removed mechanically by surgery. Cardiac surgery for endocarditis would involve removal of all the infected tissues, valve replacement is considered, especially if you are infected with virulent strains of bacteria, have a fungal infection or prosthetic valve failure.
Attribution: Avallain