There is a very easy answer to that: twice a year, ideally when the seasons change (from warm to cold and vice versa). The reason being that when winter comes, the central heating comes on. This means that your house will usually have a much drier air to it, which will affect the piano. At the end of winter, once the heating comes off, the windows are opened, the central heating is switched off, sunlight might hit the piano and slightly moister air might surround the piano – and the wood will absorb this moisture.
Pianos are mostly made of wood, metal and felt, and the wood in particular will absorb and release moisture with changes in humidity and temperature. This will affect the tuning of the piano, and these changes mostly occur as the seasons change. So as a rule of thumb, October/November and then again around May are usually good times to call your tuner. He will normally offer to call you every 6 months to arrange an appointment anyway.
If you don’t have your piano tuned at these intervals the tuning of the piano will start dropping. This can create real problems if it is left too long, as the tuner can then not immediately tune it up to what is called concert pitch, as the added extra tension would make the piano frame crack. Unlike a guitar or violin or double bass, there is a huge amount of pressure on piano strings, something like 20 tons on the whole (iron) frame. This means that tuning up all strings would increase the overall pressure on the frame by too much, and the frame would break. Violins, guitars, bass guitars, etc are not made of metal, so cannot have such high string tension, and you can easily detune a guitar and tune it back up again without any worries, but this cannot be done with a piano.
Unlike with the aforementioned violins or guitars, you cannot tune a piano yourself. You need specialist wrenches and other equipment (and piano strings aren’t freely available in shops), but more importantly it is quite a skilled and difficult job to tune a piano, and this takes several years of training.
If you play your piano a lot, and hit the keys hard, you may need to have the piano tuned more often, and if you are recording it, you will need to have the piano tuned just before the recording. In recording studios and concert halls pianos are tuned before every performance/recording, and I have seen it happen that during a jazz festival the tuner came on stage between acts to tweak the piano a little. Not a lot of fun to listen to.