The Torah requires that terumot and ma’asrot – tithes given to kohanim and levi’im – be taken from produce after it is harvested. Fruits that are ordinarily processed (e.g. grapes that are made into wine or olives that are made into oil) may have the tithes taken from the final product.
Our Gemara quotes a baraita that describes a situation where a person sets aside a barrel of wine that will be given as teruma to the kohen once the appropriate amount of wine has been used (rather than take a measure of wine for teruma each time a new batch of wine is made, this barrel was supposed to serve as a reservoir for taking tithes). If the wine in the barrel is found to have become vinegar, we can assume that it was still wine for three days after it was last checked – after that time, any wine that was tithed against this barrel must be viewed as safek – something of halakhic doubt – it may not have been tithed properly and will have to be done again.
Rashi explains that teruma on wine cannot be taken from vinegar, since they are not the same thing, and tithes must be taken from the same type of food. The Ritva argues that although vinegar and wine are considered the same, since no one would intentionally take teruma for wine from vinegar, it is considered to have been done by accident and cannot be counted.
All wine contains traces of acid, which occasionally can turn the wine into vinegar. The speed with which oxidation occurs depends on a number of different factors – the level of alcohol in the wine, the cleanliness of the container, the surrounding temperature, and more. Sine this process can take some time, there are different stages in the development of the vinegar, from an acidic taste in wine up to a full change from wine to vinegar.