Can I use 14 gauge wire on a 20 AMP electrical circuit?
You have to use the rated cable (in this case, 12 AWG), or larger, throughout the circuit. Either use 12/2 everywhere or use a 15A breaker.

Keep in mind that if you use 14/2 and 12/2 in the same circuit with a 15A breaker then there is a risk of confusion in the future if someone looks at the 12/2 coming out of the breaker and thinks "its 12 AWG, I can upsize to 20A" and doesn't realize there is 14/2 elsewhere in the circuit. So all 12 and 20A or all 14 and 15A is preferred, but mixed 12 &amp; 14 and 15A is code compliant.