How do I calculate the cost of electricity and gas that's devoted to the heating and cooling of my house during the year?
I'd guess the easiest way would be seasonally. Since there are some months when you're only heating, and some months when you're only cooling, and perhaps some months at the cusps where you're doing neither. And your other nonheating and noncooling electric and gas usage is probably really similar across the board, so that's your noise floor on the cusp months.
My local utilities put nice little seasonal usage charts on my gas and electric bills. I think they do that to help people in your position, since their computers already have all that data and so it's easy to do the calculations automatically. Though I think they do it poorly: Their charts seem to like comparing things that are useless to me, such as my usage in March this year compared to March last year, or comparing my usage to my neighborhood average.
Still, the data is there in your montly bills and I'll bet you could suss out your winter above-baseline gas heating rate, and your summer above-baseline electric cooling rate, just by doing a little data mining.