Must publicly funded research in the EU be published as open access by law?
The European commission has a webpage dedicated to this issue. In summary:

All projects receiving Horizon 2020 funding are required to make sure that any peer-reviewed journal article they publish is openly accessible, free of charge (article 29.2. Model Grant Agreement). [...]
The Commission is running a pilot on open access to research data in Horizon 2020: the Open Research Data (ORD) pilot. [...]
In 2012, the European Commission published a Recommendation on access to and preservation of scientific information encouraging all EU Member States to put publicly-funded research results in the public domain in order to strengthen science and the knowledge-based economy.
The document also asked each Member State to designate a National Point of Reference (NPR) with the task of 1) coordinating the measures listed in the Recommendation, 2) acting as an interlocutor with the Commission and 3) reporting on the follow-up. [...]

So in my understanding, everything funded directly by the EU has a mandatory open-access policy. For research funded by member States, this is only a recommendation.
See also the Open Science page on the Horizon 2020 website.

To clarify this answer: &quot;Horizon 2020&quot; is the name fo the portion of the EU budget dedicated to funding research from 2014 to 2020. I think one of the better-known bodies funded by Horizon 2020 is the European Research Council (ERC), but more generally all EU funds going to research go through Horizon 2020 (well, until 2020). The previous programs were called &quot;Framework Programs&quot; (FP, e.g. FP1, FP2, FP3... up to FP7 for the period 2007–2013).