Essential but..... Taking antibiotics to control and prevent the spread of infection is beneficial but will not guarantee the spread of infection. The particular antibiotic needs to be effective against the specific strain of bacteria, the cause of the infection needs to be addressed and the situation needs to be monitored by your dentist. It is essential but only part of the total picture.
Yes it does prevent. Penicillin is the drug of choice for dental related infections. You normally take it for one week without stopping.