If you are travelling within the EU, as long as your passport is still valid at the time you fly home you are ok.
If you are travelling to a non-EU country, you need a minimum of 6 months left on your passport when you depart from that country (though some countries may have longer time-frames, so check with their embassies or their immigration websites)