Both seem to be synonyms. In what cases should I use each one?
"Lehrveranstaltung" is a general for any teaching event: it can be used for a lecture, seminar, project, exercise session, and what-not, though typically in an academic context (i.e. at a university or other Hochschule). You can use the term both to denote a single event but also a series of events that forms an organisational unit.
- "Morgen früh habe ich drei Lehrveranstaltungen: eine Vorlesung, ein Seminar und einen Sprachkurs."
- "Diese Lehrveranstaltung findet im Sommersemester statt und gibt 5 ECTS."
"Vorlesung" is more specific and can mean several things:
A single lecture, that is a period of time during which the lecturer presents material to the class directly.
Example: "Ich war heute morgen nicht in der Vorlesung."
A series of lectures, typically over the course of a term ("Semester").
Example: "Die Vorlesung X ist ziemlich spannend, aber die Übungen sind schlecht."
A whole course with several components: lectures plus exercise sessions, etc. The proper term for that would be "Modul" (cf. Bologna reform) but "Vorlesung" has stuck.
Example: "Nächstes Semester höre ich eine Vorlesung über X."
"eine Vorlesung hören" here means "to take a course"
The german verb "vorlesen" means "read aloud". It means that one person is reading some written text aloud and all other people who are present are listening. In ancient times this was how teaching happened is schools and universities. (Some bad teachers still use this style of teaching nowadays.)
"Die Vorlesung" is the noun that is build from the verb "vorlesen". "Die Vorlesung" is the name for the process of reading aloud in front of listeners.
Today the noun "Vorlesung" does not necessarily mean that someone is reading some text out of a book. But it still means, that one person (the teacher/lector) is standing in front of a group of listeners (the students) while teaching them ("Frontalunterricht" = frontal teaching). And it means that this is happening in a Universität or Fachhochschule. If a teacher is speaking to students in a school it is NOT called "Vorlesung"! In this case it is called "Unterricht". (You don't use the word "Unterricht" at Universität or Fachhochschule!)
As Alex wrote in his answer the verbatim translation of "Lehr-Veranstaltung" is "Teach-Event". This can be every event where people are taught. Any kind of exercises, excursions, seminars, group-work, even with the teacher replaced by a computer program (e-teaching) can be a "Lehrveranstaltung". A "Vorlesung" is just one kind of "Lehrveranstaltung".
But what I said about "Vorlesung" is true for "Lehrveranstaltung" to: This term is used only in a "Universität" or "Fachhochschule". If students from a school are on an excursion this is NOT a Lehrveranstaltung, but an extraordinary kind of "Unterricht".