I have given a derivation of the needed formulae in this math.SE answer. As already mentioned by belisarius, the canonical method for finding the equation of the least-squares line constrained to pass through the origin in Mathematica would be either of

Fit[data, {x}, x]

which produces the explicit linear function, or

FindFit[data, m x, m, x]

which produces just the slope of the best-fit line as a replacement rule.

To handle the case of a least-squares line constrained to pass through an arbitrary point $(h,k)$, you can again use either of Fit[] or FindFit[], but things are slightly trickier. (I'll leave the task of encapsulating that method in a Mathematica routine as an exercise.) For this answer, I'll present the explicit formula, as implemented in Mathematica:

Important consideration with this approach: the interior point method (which is used for all constrained fits unless Method -> NMinimize is specified) requires that the residual and any additional constraints be twice differentiable, preferably analytically. If not, it will usually have trouble converging.
–
Oleksandr R.Sep 17 '12 at 20:32

@OleksandrR. Good point, thanks, I was not aware of this - is it in the documentation ?
–
b.gatessucksSep 18 '12 at 11:15

Mathematica is a registered trademark of Wolfram Research, Inc. While the mark is used herein with the limited permission of Wolfram Research, Stack Exchange and this site disclaim all affiliation therewith.