Prophylactic antibiotic administration aims to maintain the postoperative wound environment. It is difficult to select appropriate prophylactic antibiotics to minimize the development of antibiotic resistant bacteria and the occurrence of complications. The purpose of this study was to compare the prophylactic effect of narrow spectrum antibiotics (cefazolin) with that of wide spectrum antibiotics (piperacillin) in preventing infection following third molar extraction. In addition, the effect of postoperative cefazolin administration was examined. This retrospective study included 350 patients who underwent third molar removal under general anesthesia. The patients were divided into three subgroups: preoperative cefazolin (N = 122), pre- and postoperative cefazolin (N = 101), and pre- and postoperative piperacillin (N = 127). The patients in the piperacillin group were administered the antibiotic preoperatively and postoperatively for 3 days. The patients in the preoperative cefazolin group were administered cefazolin preoperatively only. The patients in the pre- and postoperative cefazolin group were administered cefazolin preoperatively and postoperatively for 1 day. Surgical site infections (SSIs) were identified based on the Clavien-Dindo 30-day postoperative classification. There was a significant difference among the three groups of patients who had third molars classified as position C using the Pell and Gregory classification, according to the degree of impaction of the impacted third molar (P = 0.015). Our analysis showed that the number of SSI did not significantly differ between the three antibiotic treatment groups (P = 0.671). These results suggest that preoperative administration of cefazolin is as effective as postoperative administration of broad-spectrum antibiotics such as piperacillin.