Annual ryegrass toxicity (ARGT) is an often-fatal poisoning of livestock that consume annual ryegrass infected by the bacterium Rathayibacter toxicus. This bacterium is carried into the ryegrass by a nematode, Anguina funesta, and produces toxins within seed galls that develop during the flowering to seed maturity stages of the plant. The actual mechanism of biochemical transformation of healthy seeds to nematode and bacterial gall-infected seeds remains unclear and no clear-cut information is available on what type of volatile organic compounds accumulate in the respective galls. Therefore, to fill this research gap, the present study was designed to analyze the chemical differences among nematode galls (A. funesta), bacterial galls (R. toxicus) and healthy seeds of annual ryegrass (Lolium rigidum) by using direct immersion solid-phase microextraction (DI-SPME) coupled with gas chromatography–mass spectrometry (GC-MS). The method was optimized and validated by testing its linearity, sensitivity, and reproducibility. Fifty-seven compounds were identified from all three sources (nematode galls, bacterial galls and healthy seed), and 48 compounds were found to be present at significantly different (p < 0.05) levels in the three groups. Five volatile organic compounds (hexanedioic acid, bis(2-ethylhexyl) ester), (carbonic acid, but-2-yn-1-yl eicosyl ester), (fumaric acid, 2-ethylhexyl tridec-2-yn-1-yl ester), (oct-3-enoylamide, N-methyl-N-undecyl) and hexacosanoic acid are the most frequent indicators of R. toxicus bacterial infection in ryegrass, whereas the presence of 15-methylnonacosane, 13-methylheptacosane, ethyl hexacosyl ether, heptacosyl acetate and heptacosyl trifluoroacetate indicates A. funesta nematode infestation. Metabolites occurring in both bacterial and nematode galls included batilol (stearyl monoglyceride) and 9-octadecenoic acid (Z)-, tetradecyl ester. Among the chemical functional group, esters, fatty acids, and alcohols together contributed more than 70% in healthy seed, whereas this contribution was 61% and 58% in nematode and bacterial galls, respectively. This study demonstrated that DI-SPME is a valid technique to study differentially expressed metabolites in infected and healthy ryegrass seed and may help provide better understanding of the biochemical interactions between plant and pathogen to aid in management of ARGT.