Subtractor op-amp configuration to find the diference of 2 signals
It is not hard to show that the output voltage of your circuit is:
$$\text{V}_\text{out}=\text{V}_2\cdot\frac{\text{R}_\text{g}}{\text{R}_2+\text{R}_\text{g}}\cdot\frac{\text{R}_1+\text{R}_\text{f}}{\text{R}_1}-\text{V}_1\cdot\frac{\text{R}_\text{f}}{\text{R}_1}\tag1$$
So, when we make \$\text{R}:=\text{R}_\text{f}=\text{R}_1\$ we get:
$$\text{V}_\text{out}=\text{V}_2\cdot\frac{\text{R}_\text{g}}{\text{R}_2+\text{R}_\text{g}}\cdot\frac{\text{R}+\text{R}}{\text{R}}-\text{V}_1\cdot\frac{\text{R}}{\text{R}}\tag2$$
Simplifying gives:
$$\text{V}_\text{out}=\text{V}_2\cdot\frac{2\text{R}_\text{g}}{\text{R}_2+\text{R}_\text{g}}-\text{V}_1\tag3$$
So, we need:
$$\frac{2\text{R}_\text{g}}{\text{R}_2+\text{R}_\text{g}}=1\space\Longleftrightarrow\space2\text{R}_\text{g}=\text{R}_2+\text{R}_\text{g}\space\Longleftrightarrow\space\text{R}_\text{g}=\text{R}_2:=\text{k}\tag4$$
So, we get:
$$\text{V}_\text{out}=\text{V}_2\cdot\frac{2\text{k}}{\text{k}+\text{k}}-\text{V}_1\tag5$$
Simplifying gives:
$$\text{V}_\text{out}=\text{V}_2-\text{V}_1\tag6$$

So, we need \$\text{R}_\text{g}=\text{R}_2\$ and \$\text{R}_\text{f}=\text{R}_1\$.