For arbitrary spaces it certainly isn't true. For instance, if $X$ is totally path-disconnected (e.g., $X=\mathbb{Q}$), then your condition is trivial, but not every map out of $X$ is continuous unless $X$ is discrete.
To characterize the spaces for which it is true, consider the following properties of a topological space $X$:
- $X$ is well-graphed if it has your property for arbitrary $Y$: that is, a map $X\to Y$ is continuous iff its graph over every path-connected subspace of $X$ is path-connected.
- $X$ is path-generated if for any $Y$, a map $X\to Y$ is continuous iff its composition with every continous path $[0,1]\to X$ is continuous. (For more about this property see this answer of mine; in particular, a path-generated space must be locally path-connected and sequential.)
- $X$ is arc-generated if for any $Y$, a map $X\to Y$ is continuous iff its composition with every embedding $[0,1]\to X$ is continuous.
We then have the following theorem:
Theorem: Every arc-generated space is well-graphed, and the converse holds for Hausdorff spaces. Every well-graphed space is path-generated.
Proof: Suppose $X$ is well-graphed and $f:X\to Y$ has the property that the composition of $f$ with every path in $X$ is continuous. Then the graph of $f$ over every path-connected subspace is path-connected, since every path in $X$ lifts to a path in the graph. Thus $f$ is continuous, so $X$ is path-generated. Moreover, if $X$ is Hausdorff, then it would suffice to assume the composition of $f$ with every embedding $[0,1]\to X$ is continuous, since in a path-connected Hausdorff space any two points are connected by a path which is an embedding, so $X$ would be arc-generated.
Conversely, suppose $X$ is arc-generated. Let $f:X\to Y$ be a map whose graph over every path-connected subset is path-connected. To show $f$ is continuous, it suffices to show $fg$ is continuous for every embedding $g:[0,1]\to X$. Since $g$ is an embedding, the graph of $fg:[0,1]\to Y$ is homeomorphic to the graph of $f$ restricted to the image of $g$. By hypothesis, the latter graph is path-connected, so the graph of $fg$ is path-connected. Now take a path $h$ from $(0,f(g(0)))$ to $(1,f(g(1)))$ in this graph. The first coordinate of $h$ is a continuous surjection $p:[0,1]\to[0,1]$, which is automatically a quotient map since the domain is compact and the codomain is Hausdorff. The second coordinate of $h$ is then the map $fgp:[0,1]\to Y$ and is continuous since $h$ is. But since $p$ is a quotient map, this implies $fg$ is continuous, as desired. $\blacksquare$
In particular, $\mathbb{R}$ is arc-generated and thus well-graphed, so your statement is true for the motivating example of maps $\mathbb{R}\to\mathbb{R}$.
As a counterexample to show that a Hausdorff path-generated space need not be well-graphed (or equivalently, arc-generated), let $X$ be the 1-point compactification of the set $$A=[0,\infty)\times\{0\}\cup\mathbb{N}\times[0,1]\subset\mathbb{R}^2.$$ Then $X$ is path-generated (indeed, it is a quotient of $[0,1]$, by a path that goes from $(0,0)$ off to $\infty$ taking a detour on each $\{n\}\times[0,1]$ along the way). However, I claim $X$ is not well-graphed. Consider the map $f:X\to[0,1]$ that is the first projection on $A$ and maps $\infty$ to $0$. Then $f$ is not continuous at $\infty$, since the points $(n,1)\in A$ approach $\infty$ as $n$ gets large but $f(n,1)=1$ and $f(\infty)=0$. However, the graph of $f$ over any path-connected set is path-connected, since any path-connected subset that contains both $\infty$ and a point $(n,t)$ for $t>0$ must also contain the path from $(n,t)$ down to $(n,0)$ and then the horizontal path from $(n,0)$ out to $\infty$, and $f$ is continuous on both of these paths.
I don't know whether there is a (necessarily non-Hausdorff) well-graphed space that is not arc-generated.