Heat the vegetable oil in a wok or large frying pan over medium heat. Add the Sichuan peppercorns and stir-fry for 1 minute or until fragrant.
Add the garlic, ginger, onion, and half of the green onions. Stir-fry for 2-3 minutes or until the onions are soft.
Add the spicy bean paste and chili flakes (if using) and stir-fry for 1 minute.
Add the diced tofu and stir-fry gently for 2-3 minutes or until the tofu is heated through.
In a small bowl, mix together the soy sauce, rice vinegar, cornstarch, and water. Pour the mixture into the wok and stir gently to combine.
Increase the heat to high and bring the mixture to a boil. Reduce the heat to medium-low and simmer for 2-3 minutes or until the sauce has thickened and the tofu is coated evenly.
Adjust the seasoning with salt if necessary.
Serve hot, garnished with the remaining green onions.