One can show that if $G$ is a graph on $n$ vertices and does not contain a path (cycles do not count) of length $k$, then $e(G) \leq \frac{k-1}{2}n$ (by induction - remove a vertex of minimal degree which turns out to be $\leq \frac{k-1}{2}$ by Ore's theorem). There are certainly examples attaining this for $k$ dividing $n$ - say, $\frac{n}{k}$ disjoint copies of the complete graph on $k$ vertices.
So in general my guess if that the possible maximum for any $n$ and $k$ is $\lfloor \frac{k-1}{2}n \rfloor$. How can we describe all extremal graphs?