Medicine is not my area of expertise, but starting with American and Canadian publications I was able to trace back the use of protective masks in modern evidence-based medicine to Germany. The starting point seems to have been the following publication:
Carl Flügge, "Ueber Luftinfection", Zeitschrift für Hygiene und Infectionskrankheiten, Vol. 25, 1897, pp. 179-224
This publication was usually cited as "Atmospheric infection" in English-language publications of the time. In five years of systematic research, Flügge and his team carefully examined the conditions under which fine dust particles and small droplets detach from surfaces of various kinds, and how far and long they can carry an infectious load (represented by Bacillus prodigiosus and Bacillus megaterium), detected through the use of plates with culture medium. Key findings were that the finest dust particles and smallest droplets capable of transmission could stay suspended in air for 4 to 5 hours, that transport of these required only minimal airflow (much smaller than anticipated), and that speaking, coughing, and sneezing would spread droplets over distances of several meters.
While transmission by dust particles had apparently been considered prior to Flügge, his major contribution was pointing out the existence of transmission by droplets, which also applies to bacteria that cannot survive desiccation. He concludes that one should expect that transmission by droplets frequently occurs in diphtheria, TB, influenza, whooping cough, pneumonia, and pneumonic plague and that this risk is significantly higher in closed rooms than in the open air. He also points out that infection by droplets presents a new mode of transmission not previously considered in
the infection of surgical wounds.
W. Hübener, "Ueber die Möglichkeit der Wundinfection vom Munde aus und ihre Verhütung durch Operationsmasken," Zeitschrift für Hygiene und Infectionskrankheiten, Vol. 28, 1898, pp. 348-372, referencing Flügge, examined the possibility of the transmission of infections from the mouths of surgical personnel to wounds and its prevention by the use of surgical masks. I am fairly certain that this is the origin of the surgical mask in common use today.
Hübener appears to have been employed by the same surgical institute in Breslau that previously had pioneered the use of surgical caps. There is a picture of a man (the author himself?) wearing a mask of Hübener's design on page 357 in the article. The mask was constructed from layers of gauze, and there is experimental data on the effectiveness of the mask in reducing the spread of infectious droplets using single-layer and double-layer construction, separately measured under conditions of speaking, shouting, coughing, and sneezing. The paper discusses the use of masks in cases of TB, influenza, and leprosy. It mentions that the effectiveness in the case of leprosy seemed minimal. Hübener mentions that masks protect in two ways:
In solchen Fällen wird die Maske nicht nur bei bereits Inficirten eine Propogation der Keime nach aussen verhindern, sondern auch gesunde, noch nicht inficierte Personen durch ihr Tragen gegen die Infection schützen"
My translation: In these cases the mask will not only prevent the propagation of microbes emanating from an infected person, but wearing it will also protect a person not yet infected against the infection.
B. Fränkel, "Zur Prophylaxe der Tuberculose", Berliner Klinische Wochenschrift, Vol. 36, No. 2, January 8, 1899, pp. 21-27, also inspired by Flügge's work and independently of Hübener, examined the utility of masks in the specific context of preventing the spread of TB. The author considers whether masks should cover just the mouth or both mouth and nose (and favors the former) and what type of fabrix should be used to construct it. Based on his own work he recommends that TB patients always wear a mask when around other people, the only drawback being conspicuous appearance.
Carl Flügge, "Die Verbreitung der Phthise durch staubförmiges Sputum und durch beim Husten verspritzte Tröpfchen", Zeitschrift für Hygiene und Infektionskrankheiten, Vol. 30, 1899, pp. 107-124, discusses the spread of TB by dried sputum particles and droplets spread by coughing. Its general recommendation is "social distancing" of one meter for TB patients in public settings. The author is of the opinion that the wearing of protective masks as recommended by B. Fränkel should be restricted to particular cases where the environment of a TB patient needs to be protected as completely as possible.
Even with the effectiveness of masks in cases of diseases transmitted by the recently discovered droplet infections established in principle, there was thus discussion on the specifics of mask wearing from the very beginning. Twenty years later, the benefit and use of masks appears to have been generally accepted by the medical community, as evidenced by the following quote (emphasis mine):
Brewster C. Doust and Arthur Bates Lyon, "Face masks in infections of the respiratory tract", Journal of the American Medical Association, Vol. 71, No. 15, October 1918, pp. 1216-1219:
The use of face masks by those whose duties necessitate their coming in contact with cases of respiratory infection has now become general. [...] We have therefore undertaken experiments with some of the commoner types of masks in order to prove their efficiency or nonefficiency in preventing the dissemination of infectious material from the mouth during the acts of speaking or coughing.