A method for controlling nematode includes treating a plant or soil with a composition comprising a grammicin compound of Formula 1 or an agriculturally acceptable salt thereof. The grammicin compound may be isolated from a Xylaria grammica strain so that it is harmless to a human body, does not cause any environmental contamination, and exhibits an excellent control activity against root knot nematodes. Thus, it can be advantageously used for developing an environment-friendly natural nematicide and production of a high value-added organic agricultural product.