Neither are ideal. If you picked one of the two on the SATs as the "most correct", you would be wrong.
The comma after "sometimes" is debatable I think, although I would argue it's unnecessary.
But the statement would be better made as follows:
Sometimes the water that comes from this tap is dirty.
Here, we've eliminated the "out of" which is a double-preposition and never ideal.
"Bad" isn't very descriptive: does the water come out and hurt people?
And we've eliminated "comes out" which is a dangling participle (when saying "comes out", it's ideal to have that answer "comes out of what?" i.e. the water comes out of the tap dirty vs. The water comes out dirty.
Of course both get the point across, but just trying to help answer your question.