I think one can push through the probabilistic arguments of Tim Gowers and Fedor Petrov in the general case, as follows.
Let $c$ be a constant such that the number of red edges in $G[S]$
is at most $c|S|$ for every $S \subseteq V(G)$. One can order the vertices of $G$: $v_1, v_2, \ldots, v_n$, so that every vertex has at most $2c$ neighbors with lower indices. (Define the ordering starting with the highest index. If $v_n, \ldots,v_{i+1}$ are defined, set $v_i$ to be the vertex with the smallest degree in the subgraph induced by the vertices which are not yet indexed. This is a standard trick.)
Now we define a random subset $S$ of $V(G)$ recursively: if $S \cap$ {$v_1, \ldots, v_i$} is chosen put $v_{i+1}$ in $S$ with probability $1/2$ if it is not joined by a red edge to any of the vertices already in $S$, otherwise don't put it in $S$. Then $S$ is red-free
and, just as in Fedor's answer, we can see that the probability that a pair of vertices $u$ and $v$ joined by a blue edge both lie in $S$ is at least $2^{-4c-2}$. Therefore the number of blue edges is at most
$2^{4c+2}c' \mathbf{E}[|S|] \leq 2^{4c+1}c'|V(G)|,$
where $c'$ is the constant implicitly present in the condition on the density of the blue edges.
$$f(n,k)= (n-k)(k-1)+\frac{k(k-1)}{2}, \; \mathrm{for} \; n \geq k, $$
$$f(n,k) = \frac{n(n-1)}{2}, \; \mathrm{for} \; n \leq k. $$
Proof: Every graph with no $k$-core on $n$ vertices contains a vertex of degree $\leq k-1$ which one can delete, obtaining a graph with no $k$-core. Thus $$f(n,k) \leq f(n-1,k) + k-1.$$
The formula now follows by induction. In the base case $n \leq k$ the formula gives the number of edges in the complete graph.
For an example that the bound can be achieved, let $G$ be a graph with $V(G) = \{1,2, \ldots, n \}$ and let the vertices $i$ and $j$ be adjacent if and only if $|i-j| < k$. It is easy to check that $G$ has no $k$-core and has the right number of edges.
Best Answer
The answer is $\lfloor \frac{3}{2}(n-1)\rfloor$. First note that if $G$ is $2$-connected and even-cycle-free, then $G$ must just be an odd cycle. To see this, consider an ear-decomposition of $G$. If $G$ is not just a cycle, then $G$ contains a cycle and an ear. However, by parity considerations, a cycle and an ear always contains an even cycle.
Now let $G$ be an arbitrary even-cycle-free graph and consider its block-cut-tree $T$. By the previous remark, each block of $G$ is an odd cycle or just an edge. To maximize the number of edges, each block of $G$ should be a triangle. Thus, the maximum number of edges is attained by a 'tree of $k$ triangles.' This graph has $3k$ edges and $2k+1$ vertices. For $n$ even (say $n=2k+2$), the maximum is attained when $T$ has exactly $k$ blocks which are triangles and exactly one block which is an edge. This is a complete characterization of the extremal examples.