TemperatureData = {{1, -1.4}, {2, - .2}, {3, 3.7}, {4, 
            8.9}, {5, 13.8}, {6, 17.2}, {7, 19}, {8, 18.5}, {9, 14.8}, {10, 
            9.1}, {11, 
            4.1}, {12,  .3}, {13, -1.4}};
pomfce[month_] = Interpolation[TemperatureData][
          month];
Temperature[m_] := 
        pomfce[m] /; 1 ≤ m < 13;
Temperature[m_] := 
        Temperature[m - 12] /; 
          m ≥ 13;
Temperature[m_] := 
        Temperature[m + 12] /; m < 1;
teplsec[t_] := 
        Temperature[(t/(30.5*24*3600))];
touttopim = 14;
Plot[{teplsec[t], touttopim}, {t, 0, 2*12*30.5*24*3600}, 
        AxesLabel -> {"t[s]", "T[°C]"}, 
        PlotLabel -> "  Temperature as a function of time", 
        PlotStyle -> {{Thickness[0.01], GrayLevel[0]}, {Thickness[0.01], 
              RGBColor[1, 0, 0]}}];
castopenipoc = 
        t /. FindRoot[
            teplsec[t] == touttopim, {t, 2*(10^7), 
              3.5*(10^7)}];
Print["starting time for heating =  ", 
      castopenipoc, "  s"]
castopenikonec = 
        t /. FindRoot[
            teplsec[t] == touttopim, {t, 4*(10^7), 
              5*(10^7)}];
Print["ending time for heating =  ", 
      castopenikonec, "  s"]

heatloses[T_] = 
        100 + 50*(20 - T);

energyforheating = 
        NIntegrate[
          heatloses[teplsec[t]], {t, castopenipoc, 
            castopenikonec}];
Print["energy for heating =  ", 
      energyforheating, "  J"]