This is easier said than done. Unlike merging photos for exposure, every time you refocus the shape of the subject changes slightly, so each picture needs to be aligned not only for x and y coordinates but also for depth by adjusting magnification. All tricky stuff for software but the free program "Combine ZP" available from: http://www.hadleyweb.pwp.blueyonder.co.uk/CZP/News.htm does the job admirably (though it does take some learning). Here is a dandelion composited from 5 differently focused frames in 'CombineZP':
Although the differently focussed frames can be achieved by adjusting focus on the lens, it is much easier with subjects this size to use a focusing rail which allows sub-mm adjustments. All five frames were shot at ISO 100, with a 70-300 Tamron lens at 185mm and f11 for 0.7 seconds.