Joseph Smith teaches that the ordinances were instituted in heaven before the foundation of the world.
Sermon given on June 11, 1843, in Smith, Joseph, Jr., Andrew H. Hedges, Alex D. Smith, and Brent M. Rogers, Journals: May 1843-June 1844. The Joseph Smith Papers, Journals 3, ed. Ronald K. Esplin and Matthew J. Grow (Salt Lake City, UT: The Church Historian's Press, 2015), p. 32.
the pri[n]ciple & law of that pri[e]sthood was predicated up[o]n the gathe[rin]g of the people in every age of the world. Jesus did every thing possible to gather the people. & th[e]y would not be gathered [p. [241)) and he poured out curses up[o]n the[m] Ordinances were instituted in heavn before the f[o]undation of the world of in the pri[e]sthood. for the salvati[o]n of man. not be alterd. not to be changed.- all must be saved upon the same principle. 118
118. Wilford Woodruff's account of this sermon clarifies JS's point: "He then asked what was the object of Gathering the Jews together or the people of God in any age of the world, the main object was to build unto the Lord an house whereby he could reveal unto his people the ordinances of his house . . . for their are certain ordinances & principles chat when they are caught and practized, must be done in a place or house built for that purpose this was purposed in the mind of God before the world was." (Woodruff, Journal, 11 June 1843.)