Do you need a comma before "such as"?
Whether you need commas or not all depends on how important that information is in the phrase introduced by such as. That is, whether that phrase is restrictive or non-restrictive. In other words, is this information relevant for this sentence or not, would that sentence still make sense (also in context) if you leave it out.
Ethical reasons such as religion have a huge part in abortion.
If you write it like this you the reader would expect you to talk about religion in the following sentences. It is restrictive.
Ethical reasons, such as religion, have a huge part in abortion.
Here the focus lies on the ethical reasons with religion given as supporting example. It is non-restrictive.
To conclude, you either have a comma before such as and after the phrase introduced by it or no comma at all. It all depends on whether that information is important for the sentence and the following text or not.
If you ask uncle Google about "relative clause" you should find much info on restrictive and non-restrictive usage of clauses (Such as does not introduce a full clause; in your example it is part of a prepositional phrase). And finally, the Chicago manual of style even has some info on the comma usage with such as: Chicago Manual Of Style.
“Such as” sometimes needs a comma and sometimes doesn't. A good trick to work out whether to include the comma is to try removing the part of the sentence that starts with "such as” and ask yourself if the meaning of the sentence has changed.
If the answer to that is no, then “such as” is a nonrestrictive (i.e. not essential) clause, and so it needs to be separated by commas. E.g.
The garden is filled with flowers, such as tulips and daffodils.
In this case, if we remove the “such as” phrase, we’re left with “The garden is filled with flowers.” This makes perfect sense on its own. Specifying the types of flowers is an additional explanatory detail, not an essential clause, so it should be preceded by a comma.
If removing the “such as” phrase does change the sentence meaning, then you have a restrictive clause and so should not use a comma. E.g.
Countries such as Mali and Senegal have hot climates.
Here, if we remove the phrase “such as Mali and Senegal,” then we’re left with the sentence “Countries have hot climates.” This implies that all countries have hot climates, which is demonstrably not true. Therefore, this is an essential phrase, and we should not use commas around it.
Here’s an article I wrote that answers this in more depth.