You get energy from eating fruits and other foods like eggs (from the Bunny Day event) and turnips. The energy can be used to break rocks and transplant trees, but what if I don't want the energy? How can I get rid of it?
You can rid of the energy by using it. Digging up and planting the same tree over and over again will work, and does no damage to the tree since you plant it in the same state as it was dug up, with even fruits left intact.
This Polygon article also states that toilets, if you can find one, can be sat on to uh, flush all of your energy away, but finding one will be tricky since it's not one of the default recipes, and just going to it will probably be slower than transplanting unless you accidentally ate 10 turnips.
Saving and re-opening the game by using the - (minus) key also works, but is also rather laborious, and will reset your location to your house.