A comma precedes “such as” when what follows is an example of whatever went before. In this case, it is nonrestrictive. (For nonrestrictive constructions: use a comma.)
My favorite flavors of candy are fruit flavors, such as cherry and lemon.
The sentence is complete and the idea is complete without the list of specific instances. The list just illustrates the meaning of “fruit flavors” but does not restrict it. So it is nonrestrictive and needs a comma.
You don’t use a comma before “such as” when what follows defines or limits what went before. In this case it is restrictive. (For restrictive constructions: no comma.)
The refugees were unable to carry things such as clothes, bedding, and furniture.
Here, what comes after “such as” serves to define (restrict) the idea of “things.” The category isn’t named. The list is necessary to explain what kinds of things the refugees had to leave behind. The category might be “household goods,” but it isn’t stated–instead, the “such as” list supplies the definition. It is restrictive. No comma.
(It would be better English to say “such things as…,” but this wording stresses the parallel example.)
If you rewrote this sentence to name the category, you would then not need the comma:
The refugees were unable to carry their household goods, such as clothes, bedding, and furniture.