In a saucepan, heat the vinegar and sugar until the sugar has dissolved, stirring constantly. Just as it starts to simmer, turn off the heat. Add the salt, peppercorns and garlic and stir to combine.
Place the onions in a glass bowl and pour the liquid over the onions. Press the onions down so the liquid immerses over all of the onions. Allow to cool for about 10 minutes.
Transfer the onions and liquid to a glass jar and cover. Place in the fridge for a few hours before serving. Keeps in the refrigerator for up to a month.