Let $f$ be a newform of level $N$ and weight $k\geq 2$. We say $f$ has CM by the quadratic field $K$ is there exists a quadratic extension $K/\mathbb Q$ such that if $\eta_{K/\mathbb Q}$ is the quadratic character whose kernel is $G_{K}$ then the automorphic representation $\pi(f)$ of $\operatorname{GL}(2,\mathbb A_{\mathbb Q})$ is isomorphic to $\pi(f)\otimes\eta_{K/\mathbb Q}$. If this is true, then $K$ has to be an imaginary quadratic extension. More generally, if $F$ is a totally real field and $\pi$ is an automorphic representation (EDIT: as wccanard points out, here again the condition that the weight should be greater than $2$ has to be included) of $\operatorname{GL}(2,\mathbb A_{F})$ isomorphic to $\pi\otimes\eta_{K/F}$ for $K/F$ quadratic then $K$ is a CM extension (a totally imaginary quadratic extension of $F$).
As Marc Palm writes, when $f$ has CM by $K$ there exists a character $\chi$ of $\mathbb A_{K}^{\times}/K^{\times}$ such that for all finite place $v$, the $L$-factor $L_{v}(f,s)$ of $f$ is equal to the product $\underset{w|v}{\prod}L_{w}(\chi,s)$ of $L$-factors of $\chi$ over places of $K$ above $v$. A highbrow version of this last statement is that $\pi(f)$ is isomorphic to the automorphic induction of $\chi$ from $K$ to $F$.
Let $f$ be a newform of level $N$ and weight $k\geq 2$. We say $f$ has CM by the quadratic field $K$ is there exists a quadratic extension $K/\mathbb Q$ such that if $\eta_{K/\mathbb Q}$ is the quadratic character whose kernel is $G_{K}$ then the automorphic representation $\pi(f)$ of $\operatorname{GL}(2,\mathbb A_{\mathbb Q})$ is isomorphic to $\pi(f)\otimes\eta_{K/\mathbb Q}$. If this is true, then $K$ has to be an imaginary quadratic extension. More generally, if $F$ is a totally real field and $\pi$ is an automorphic representation of $\operatorname{GL}(2,\mathbb A_{F})$ isomorphic to $\pi\otimes\eta_{K/F}$ for $K/F$ quadratic then $K$ is a CM extension (a totally imaginary quadratic extension of $F$).
As Marc Palm writes, when $f$ has CM by $K$ there exists a character $\chi$ of $\mathbb A_{K}^{\times}/K^{\times}$ such that for all finite place $v$, the $L$-factor $L_{v}(f,s)$ of $f$ is equal to the product $\underset{w|v}{\prod}L_{w}(\chi,s)$ of $L$-factors of $\chi$ over places of $K$ above $v$. A highbrow version of this last statement is that $\pi(f)$ is isomorphic to the automorphic induction of $\chi$ from $K$ to $F$.