In a previous experiment, an L‐amino acid oxidase (LAAO) from the serum of Siganus oramin (SR) had a strong inhibitory effect on Streptococcus agalactiae. But we did not know inhibition mechanisms of SR‐LAAO against S. agalactiae. In this study, after S. agalactiae was treated with SR‐LAAO and hydrogen peroxide (H2O2) at the minimal bactericidal concentration, scanning and transmission electron microscopy showed that there are differences in cell size, degree of surface wrinkle and internal dissolution. These observations suggested that H2O2 can cause more serious damage to S. agalactiae than SR‐LAAO. The metabolites of S. agalactiae that has been treated with SR‐LAAO or H2O2 were analysed and compared. A total of 438 positive ion metabolites were detected and 129 were significantly different between SR‐LAAO and H2O2. We detected 351 negative ion metabolites, of which 104 were significantly different. It should be noted that in the differential amino acid analysis, L‐ergothioneine was the most significantly up‐regulated amino acid in the H2O2 treatment group, which suggested that it may be related to the function of SR‐LAAO. Direct mixing of L‐ergothioneine and SR‐LAAO did not extend the inhibition zone, which suggested that ergothioneine could not react directly with SR‐LAAO, to enhance the antibacterial ability. However, the results of challenge experiments and the qRT‐PCR experiment proved that ergothioneine can up‐regulate the expression of SR‐LAAO and reduce the mortality of S. agalactiae‐challenged zebrafish. This study further revealed the antibacterial mechanism of fish LAAO and provided a foundation for future research.