Caulk and Paint
When window frame damage is minor, new caulk and paint are generally enough to seal out any further water damage. Use exterior grade caulk that is specially made for windows and doors and always caulk before painting. It is good practice to scrape and sand the window frame before painting it with exterior paint.
When the wood is rotten on the surface, wood filler can be used to restore the damaged spot to bring the window back to its original state. The rotten spots have to be removed with a chisel. After these areas are removed and dry, then the wood filler can be added with a putty knife. The wood filler has to dry for several hours before being sanded and painted. Once painted, the window frame is complete. This method can be used on window trim as well.
Replace The Rotten Piece
Sometimes there is nothing you can do to repair the wood but replace it with a different piece. Remove the rotten piece carefully and set it aside while you sand, scrap, and prepare the rest of the window frame for painting. Take the piece to a cabinet maker who will charge you a small fee for replicating the piece. Then simply take the finished piece, add wood glue to the grooves of the piece and slide the new piece into the frame to replace the old one. Clamp if necessary, but let the glue set for a day before sanding and painting. This is an easy way to get a perfectly replicated piece for a very reasonable cost without replacing a window.