To be drawn TLine needs a coordinates space. One way to define the coordinates spaces is simply to draw the histogram. In that sense your approach is correct. If you want to avoid drawing twice the same histogram you can first define the space with DrawFrame. Your macro becomes:
void foxwise2(){
TCanvas* canvas = new TCanvas();
TH1F* h = new TH1F("h", "", 100, -10, 10);
h->FillRandom("gaus", 100000);
h->SetFillColor(2);
h->SetLineWidth(3);
TLine* l = new TLine(-5, 0, 5, h->GetMaximum());
l->SetLineColor(4);
l->SetLineWidth(8);
l->SetLineStyle(9);
canvas->DrawFrame(h->GetXaxis()->GetXmin(),h->GetYaxis()->GetXmin(),
h->GetXaxis()->GetXmax(),1.03*h->GetMaximum());
l->Draw();
h->Draw("same");
canvas->RedrawAxis();
}