Prepare the jars: Sterilize two pint-sized mason jars by boiling them in water for 10 minutes. Let them cool slightly before use.
Pack the tomatoes: In the sterilized jars, pack the cherry tomatoes tightly, leaving some space at the top. If using, add the thinly sliced red onion for added flavor and color.
Make the brine: In a saucepan, combine the distilled white vinegar, water, kosher salt, sugar, smashed garlic, black peppercorns, red pepper flakes, and dried oregano. Bring the mixture to a boil, stirring until the salt and sugar dissolve.
Add the basil: Once the brine is boiling, remove it from heat and stir in the torn basil leaves. This will infuse the brine with a fresh herbal aroma.
Fill the jars: Carefully pour the hot brine over the packed tomatoes in the jars, ensuring that the garlic and spices are evenly distributed. Leave about ½ inch of headspace at the top of each jar.
Seal and cool: Wipe the rims of the jars with a clean cloth to ensure a good seal. Place the lids on the jars and screw on the bands until fingertip-tight.
Process the jars: For long-term storage, process the jars in a boiling water bath for 10 minutes. Ensure the water covers the jars by at least an inch. Remove the jars and let them cool completely on a clean kitchen towel.
Storage: Once cooled, check that the lids have sealed properly (the center should not pop back when pressed). Store the jars in a cool, dark place.
