The invention discloses a preparation method of an amide or ester compound, which comprises the steps of under the protection of inert gas, taking substituted carboxylic acid, an amine compound or an alcohol compound as a raw material, and reacting in an organic solvent in the presence of a phosphine oxide compound, an acyl chloride compound and organic alkali to generate the amide or ester compound. According to the preparation method, the phosphine oxide compound and the acyl chloride compound are used as condensing agents, the organic base is used as an acid-binding agent, substituted carboxylic acid and amine or alcohol react in the organic solvent to generate the amide or ester compound, the raw materials are cheap, easy to obtain, green and non-toxic, the green and environment-friendly requirements are met, the reaction rate is high, the yield is high, racemization is not prone to occurring, the atom economic utilization rate is high, the separation and post-treatment processes are simple and easy to operate, and the method is suitable for large-scale industrial production.