Q:

Why did Max Planck forbid women from attending his lectures?

https://en.wikipedia.org/wiki/Lise_Meitner:

Encouraged by her father and backed by his financial support, she went to the Friedrich-Wilhelms-Universität in Berlin where famous physicist Max Planck allowed her to attend his lectures, an unusual gesture by Planck, who until then had rejected any woman wanting to attend his lectures.

Did Max Planck really forbid women from attending his lectures (Wikipedia does not give any reference), and if so what was the reason?

A:

It is difficult to say what Max Planck really thought on the topic, but 
I suspect that there is nothing special here about Max Planck:
exclusion of women was common at that time. In many German and other European universities women were explicitly excluded by university regulations. Apparently a professor could make an exception for some particular student, but he definitely had to make some effort for this. So I interpret the phrase "unusual gesture by Planck" not in the sense that "he forbid other women" but as "he did not care to obtain a permission" for most women.
My opinion is based on a similar case (which happened earlier)  when Weierstrass had to fight his university administration to allow Sophia Kowalewski to attend his lectures. Some details of this discussion have been preserved. Weierstrass failed in his fight with the university administration, and had to teach Kowalewski privately.
I remember one argument made by the opponents of Weierstrass: that presence of a woman in class would distract young male students from concentrating on the lecture.
EDIT. I think it would be interesting to make a list of the dates when women were
admitted for the first time as students in top universities of various countries.
I mean admitted in a normal way, not as an exception. 
According to this page:
https://www.hu-berlin.de/en/about/history/huben_html
women were admitted to Prussian universities since 1908. This is somewhat different date from what is given tor "Germany" in the answer of Mauro Allegranza who cites Wikipedia, and the difference is relevant for the case we are discussing. The statement in Wikipedia about "Germany" is suspicious, because these questions were decided separately in each German land.

A:

For some detail, see :

John L. Heilbron, The Dilemmas of an Upright Man : Max Planck As Spokesman for German Science (1987), page 37, regarding Planck's attitude towards women and academic life.

Regarding Boltzmann's student, Lise Meitner, see page 38-39 :

[After Boltzmann's suicide in 1906] Meitner went to Berlin, where with Planck's help she obtained a place in the chemical institute of his fellow professor and academician Emil Fischer. In 1912 Planck appointed her his own assistant, and two years later, together with Fischer, he defeated an effort to draw her away to the University of Prague.

Relevant dates (from Wiki) :

Max Planck in June 1880 presented his habilitation thesis [...]. With the completion of his habilitation thesis, Planck became an unpaid private lecturer in Munich, waiting until he was offered an academic position.
In April 1885 the University of Kiel appointed Planck as associate professor of theoretical physics. 
1891 - Germany : Women are allowed to attend university lectures, which makes it possible for individual professors to accept female students if they wish.
  [But regarding the too broad denomination of "Germany" in 19th Century, see Alexandre's post.]
Women were not allowed to attend public institutions of higher education in Vienna around 1900, but Lise Meitner was able to achieve a private education in physics in part because of her supportive parents, and she completed in 1901 with an "externe Matura" examination at the Akademisches Gymnasium.
Meitner studied physics and went on to became the second woman to obtain a doctoral degree in physics at the University of Vienna in 1905. 

