Your examples are correct. You can study the use of the comma in relative clauses in any good grammar book, and you'll probably fine examples and rules online if you google for "types of relative clauses". You'll learn about restrictive or defining clauses and non-defining clauses and the use of commas in them.
New words, one handy idiom, and a 2-minute quiz — delivered to your inbox to keep your streak alive.