1). Etherification of an alcohol with alkyl halides (Williamson synthesis), demands the formation of the corresponding alkoxide which cannot be effectuated with a mild base such as a tertiary amine. Thus, quaternization of a tert-aminalcohol can be effectuated by addition of an alkyl halide without preliminary protection of the alcohol group.
2). The reaction of a free carboxylic group and tertiary amine leads to the formation of the corresponding tert-ammonium carboxylate salt. The so formed carboxylate anion is rather a strong base, as deriving from a rather weak carboxylic acid. Thus, the so formed carboxylate anion can attack to the MeI and form the corresponding methyl ester by removing iodine, which is an easily eliminating group, via a SN2 mechanism. Even a little formation of the tert-ammonium carboxylate salt (e.g in DMSO) is enough because the reaction propagates according the Le Chatelier’s principle. Furthermore, the little amount of quaternary ammonium iodide that is simultaneously formed, behaves as a phase transfer catalyst that accelerate the reaction that can so occur under mild conditions. Thus, preliminary protection of the carboxylic group is necessary prior quaternization.
Selection of the protecting methods depends on the particular molecular structure and the neighboring functional groups (e.g. alcohol, phenol groups, etc.)
If esterification is the selected protecting method, don’t worry about farther amine catalyzed transesterification by the free OH group, because transesterification demands high temperatures and long reaction times, in general.