The following physiological explanation of the phrase "putting on a long face" appears in James Parsons, "The Crounian Lectures on Muscular Motion, Lecture II. Read Nov. 27, 1746," reprinted in The Philosophical Transactions (From the Year 1743, to the Year 1750) Abridged (1756):
Fig. 145. [viewable on the insert page after page 1180 of the linked periodical] shews a countenance of sorrow, whose action is weeping. In this passion the muscles that are the instruments for it's formation are: The triangularis on each side, which draw down the corners of the mouth, while the elevator labii inferioris proprius pulls up the under lip. At the same time the eyes have a principal part to act in this case ; for the aperiens palpebram is remitted, while the elevator of the eye has a little raised the pupil, which is covered by the lid, and looks languid ; the other muscles of the face are relaxed, and the difference between the rictus oris and the eyes is much lengthened. This gives occasion for the phrase commonly used, of putting on a long face, upon being sorrowful; and the relaxation mentioned causes the forlorn look.
So, evidently, "putting on a long face" was already a commonly used phrase in November of 1746, and it refers to the physiological effect on the appearance of one's face that results from tightening certain facial muscles and relaxing certain others when weeping. A second version of these lectures was published in 1747, so perhaps Merriam-Webster is dating the idiomatic use of "long face" to that publication, instead of to the public reading of the lecture in the previous year. In any event the expression seems to have been well established by 1746.
The expression also occurs in Samuel Richardson, Clarissa; or, The History of a Young Lady (1748) in a letter from Mr. Lovelace to John Belford:
The man looked pale ; and, trembling and with his fright, made a plaguy long face ; and called to one of his bodice-makers above, Joseph, come down quickly.
One early text draws an interesting connection between having a long face and having a tendency toward melancholy. From a 1665 translation by John Davies of Marin Cureau, The Art How to Know Men, Originally Written by the Sieur de La Chambre:
Of all these parts [in the Woman], the little, short, and slender, are the effects of the cold Temperament, which confines the matter, and hinders it from spreading and dilating it self. The fleshy and soft parts are the productions of the moisture, for they denote abundance of flegmatick bloud. ... Hence it comes that the forehead and face of the Man are of a square figure, and those who are inclin'd to Melancholy, have corners of the forehead ending in a sharp point, and long faces, contrary to the Flegmatick, who have them almost of a round character.
But as used in this treatise, the term "long faces" isn't an idiomatic description of people whose faces seem to grow longer at moments of melancholy. Rather it describes a permanent physical attribute that naturally accompanies a certain personality. For the sieur de la chambre, it seems, physiognomy is destiny.