The Bonsai is seen being clipped by Squidward in his gallery. While tending to the Bonsai, he notices a stray leaf hanging from the Bonsai's nose. Just before he cuts the leaf, he gets startled by SpongeBob and Patrick screaming and accidentally cuts the Bonsai's head off. The Bonsai's head then comes to life and asks Squidward to grant its final request. He agrees, and the Bonsai asks him to avenge it.
Technically, it is a topiary and not a bonsai. A bonsai is a miniturized tree, while a topiary is a bush, shrub or tree trimmed into a certain shape (in this case, Squidward's head).