To begin with, as relative pronouns, "which" can only replace things, whereas "that" can peplace both things and persons.
New words, one handy idiom, and a 2-minute quiz — delivered to your inbox to keep your streak alive.
If the 'which' clause adds new information about the noun it relates to, put a comma.
If the 'which' clause defines the noun it relates to, don't. (You can use 'that' instead of 'which' in such cases.)