The attack of a nucleophile on an acyl derivative results in the formation of a transient tetrahedral intermediate. This intermediate partitions, that is, breaks down, by a series of parallel pathways to generate a series of products which is governed by the exact nature of the intermediate and the individual microscopic rate constants for each potential pathway. For tetrahedral intermediates formed from simply acyl derivatives, it is possible to apply a simple set of rules to determine which group around the tetrahedral center is the "best leaving group", and hence, what will be the predominate product of a given reaction.
In general, for tetrahedral intermediates involving anionic leaving groups, you can assume that the best leaving group will be that group which has the strongest conjugate acid.
For example, consider the intermediate shown below. The potential leaving groups are methoxide and phenoxide. The conjugate acids of methoxide and phenolate anions are methanol, pKa=16, and phenol, pKa=9 (approximate pKavalues). The strongest acid is phenol, and the major product formed will be ethyl acetate.
Another example; the tetrahedral intermediate shown below has two potential leaving groups, chloride and phenoxide. The strongest conjugate acid is HCl, hence chloride anion is most likely to leave and the major product will be phenyl acetate.
Again, the process is simply to examine the potential leaving groups, determine which has the strongest conjugate acid (the lower pKa), reform the carbonyl, allowing that group to leave and draw the final product.