The best way to stop an animal from peeing on a table leg is to train them not to do so. However, while training, home remedies such as vinegar and mint oil can help. Both smell strong to cats and dogs.
This way, they no longer perceive the smell of urine and are deterred by the table leg at the same time, which can prevent further peeing. Depending on the animal, these home remedies can be more or less effective. If training does not help with male animals, neutering can still be used to curb the animal's urge to mark its territory.