In this paper we consider an optimal control problem for an inhomogeneous Heat equation. We transfer the problem into a moment problem. Then this moment problem is changed to measure theoretic control problem, and the new problem is converted to an infinite dimensional linear programming problem. Finally we approximate the infinite dimensional linear programming problem to a finite dimensional one and the solution to this problem is used to find a piecewise constant control for the original problem.