A good way of understanding this is with the use of Riemann functions.
Suppose we have to solve the problem
$$
L u = u_t - u_{xx} = w(x,t), \qquad 0 < x < \infty, \quad 0 < t,
$$
$$
u(x,0) = f(x), \hspace{8.4em}
$$
$$
u(0,t) = g(t). \hspace{8.4em}
$$
Let $v$ be a function with all the needed properties (so the following calculations are valid). Then,
\begin{align}
\iint_\Omega v Lu \,dx dt &= \iint_\Omega v(u_t - u_{xx})dx dt \\
&= \iint_\Omega \Big\{ (v u)_t + (v_x u - v u_x)_x - (v_t + v_{xx})u \Big\}dxdt \\
&= \iint_\Omega \Big\{ (v u)_t + (v_x u - v u_x)_x - u L^*v\Big\}dxdt,
\end{align}
where $\Omega = [0, R) \times [0,T)$ and $L^*$ is the adjoint operator of $L$. If $u$ is a solution of the original problem,
\begin{align}
0 &= \iint_\Omega \text{div} \begin{pmatrix} v_x u - v u_x \\ v u\end{pmatrix} dx dt - \iint_\Omega u L^* v\,dx dt - \iint_\Omega vw\,dxdt \\
&= \int_{\partial \Omega} \begin{pmatrix} v_x u - v u_x \\ v u\end{pmatrix} \cdot \hat{n}\,dS - \iint_\Omega u L^* v\,dx dt - \iint_\Omega vw\,dxdt, \tag{1}
\end{align}
where we have used the divergence theorem, and $\hat{n}$ is the (unitary) exterior normal vector of $\delta \Omega$.
Now,
\begin{multline}
\int_{\partial \Omega} \begin{pmatrix} v_x u - v u_x \\ v u\end{pmatrix} \cdot \hat{n}\,dS = \int_0^R (-vu)\Big|_{t = 0}\,dx + \int_0^T (v_x u - v u_x)\Big|_{x = R}\,dt \\
+ \int_0^L (uv)\Big|_{t = T}\,dx - \int_0^T (v_x u - v u_x)\Big|_{x = 0}\,dt.
\end{multline}
Using the initial and boundary conditions for $u$,
\begin{multline}
\int_{\partial \Omega} \begin{pmatrix} v_x u - v u_x \\ v u\end{pmatrix} \cdot \hat{n}\,dS = -\int_0^R v\Big|_{t = 0} f(x) dx + \int_0^T (v_x u - v u_x)\Big|_{x = R}\,dt \\
+ \int_0^L (uv)\Big|_{t = T}\,dx - \int_0^T v_x\Big|_{x = 0} g(t) dt + \int_0^T (v u_x)\Big|_{x = 0} dt
\end{multline}
If we find $v$ such that
$$
v_t + v_{xx} = 0, \qquad 0 < x < \infty,\quad 0 < t < T,
$$
$$
\lim_{R \to \infty} v = \lim_{R \to \infty} v_x = 0,
$$
and
$$
v = 0 \text{ for } x = 0,
$$
then we can rewrite eq. (1) as
$$
\int_0^L (uv)\Big|_{t = T}\,dx = \int_0^\infty v f(x) dx + \int_0^T v_x g(t) dt + \int_0^\infty\int_0^T v w(x,t)\,dxdt.
$$
"Why are we doing all this?", you may ask. The reason for this (which is also the reason why I've been so secretive about the arguments of the function $v$) is that, if
$$
v(x,T) = \delta(x-y),
$$
then
$$
u(y,T) = \int_0^\infty v f(x) dx + \int_0^T v_x g(t) dt + \int_0^\infty\int_0^T v w(x,t)\,dxdt.
$$
In other words, if we can find $v(x,y,t,T)$ such that
$$
v_t + v_{xx} = 0, \quad 0 < x < \infty, \quad 0 < t < T,
$$
$$
v(0,y,t,T) = 0,
$$
$$
v(x,y,T,T) = \delta(x-y)
$$
$$
\lim_{x \to \infty} v(x,y,t,T) = \lim_{x \to \infty} v_x(x,y,t,T) = 0,
$$
we'll be able to find the solution of the semi-infinite problem.
The function $v(x,y,t,T)$ is known as the Riemann function of $L$ (plus initial and boundary conditions).
But where, oh where, can we find a function that is related to the heat equation, the $\delta$ function and decays smoothly at infinity?
You're right! The heat kernel!
It's fairly easy to see that
$$
K(x-y,T-t) = \frac{e^{-\frac{(x-y)^2}{4 (T - t)}}}{\sqrt{4 \pi (T - t)}},
$$
is a solution of $L^* v = 0$, satisfies the $\delta$ condition and decays very well.
What about boundary conditions?
The Riemann function for this problem has to satisfy Dirichlet boundary condition. Every odd function in $x$ will satisfy the condition. Thus, a natural property for $v$ to have is
$$
v(-x,y,t,T) = -v(x,y,t,T),
$$
which can be thought as the odd extension of $v$ to $\mathbb{R}$.
Therefore,
$$
v(x,y,t,T) = K(x-y,T-t) - K(-x-y,T-t),
$$
and the solution of the original problem is
\begin{multline}
u(y,T) = \int_0^\infty v(x,y,0,T)f(x)\,dx + \int_0^T v_x(0,y,t,T) g(t)\,dt \\
+ \int_0^\infty\int_0^T v(x,y,t,T)w(x,t)\,dxdt.
\end{multline}
If we had Neumann boundary conditions instead, the same construction would lead to $v_x(0,y,t,T) = 0$, the need for $v$ to be an even function of $x$, i.e.,
$$
v(x,y,t,T) = K(x-y,T-t) + K(-x-y,T-t)
$$
and the solution
\begin{multline}
u(y,T) = \int_0^\infty v(x,y,0,T)f(x)\,dx - \int_0^T v(0,y,t,T) g(t)\,dt \\
+ \int_0^\infty\int_0^T v(x,y,t,T)w(x,t)\,dxdt.
\end{multline}
A fantastic exercise is to work out with a finite interval (where you'll have to perform a periodic extension and, in order to satisfy the boundary conditions, express $v$ as an infinite sum of heat kernels!).