Addressing the broader question of how long wooden ships could stay in active service is a tricky one because of the nature of the beast.
Until the nineteenth century, all ships were built with bio-degradable material - wood - and rigged with rope made from hemp, and canvas made from flax. In the nature of things therefore, any vessel, no matter the care taken in her building, began to deteriorate from the moment she was launched. The decline was accelerated by wind and waves and by the seepage of rainwater into the timber, a process aided by the thousands of joints in her structure each of which moved slightly with the motion of the ship. There was yet a futher hazard. English oak was the prime shipbuilding timber because of its solid durability, but it was susceptible to the gribble and the ship-worm. The gribble is the common name for Limnoria, a small crustacean of about 1/8in in length. Although its burrows are not deep they can so weaken the surface of the timber that it becomes easily eroded. The ship-worm, the Teredo Navalis, on the other hand, is 3-4in long and perhaps 3/10in in diameter. Widespread infestation by the Teredo can be a direct threat to the strength of planking and even timbers. And in tropical waters both creatures can be very much larger.
HMS Victory, Her Construction, Career and Restoration, A.McGowan (Chatham, 1999)
Composed of thousands of relatively small, weak pieces of wood, held together with wooden pins and metal fastenings, the wooden warship was a fragile structure. From the day they launched, when the hull always broke its sheer, the fixings began to weaken. Sustained hard service would worsen the condition of the hull, and if the material began to decay, loosening the the grip of the fastenings on the timbers, the whole structure would degrade. Eventually the ship would be incapable of carrying its guns, or in the worst cases simply remaining afloat, In the seventeenth century larger ships would be taken to pieces, and as much material as possible salvaged for re-use in a new ship, frequently under the same name.
(Series Preface) British Warships in the Age of Sail 1603-1714, Andrew Lambert (Seaforth, 2009)
The tradition of having ships inherit names from earlier vessels (which, as noted above, might also donate materials in varying degrees) can make it difficult to establish the true service life of a particular ship. This can be further confused when ships change names and/or owners (captured warships were often repaired and put into service with their new owners and in some cases these were recaptured or captured by a third party). Therefore, we really only have accurate records from the start of the Age of Sail when the European sevices became standing navies and acquired the corresponding bureaucracies. Even with this improved record keeping, it can be difficult to determine exactly which ship is being referred to.
Wooden warships were expensive to run. They required much larger crews than merchant ships of the same size and keeping a ship at sea in all weathers generated a lot of on-going maintenance. As a consequence, it was normal practice to mothball the bulk of a navy's warships in times of peace. This meant they were kept in a sheltered anchorage or harbor and typically had the masts & rigging removed (and often the guns as well) to reduce the strain on the ship's hull. This reduced peacetime costs and had the additional effect of increasing the ship's potential service life by reducing wear & tear.
Looking at how a famous vessel (mentioned in another answer), HMS Victory, has survived for 250 years, it's mainly because she wasn't at sea for most of her life - along with a spot of good fortune and national sentiment. The Victory was launched in 1765 but remained 'in ordinary' (i.e. mothballed as a reserve) before being fitted out and commissioned for active service in 1778. After 4 years of service in the Channel, she was paid off and had a 'middling repair', which took six months. She then spent 4 years in reserve but still required a 'large repair' before being commissioned again in 1789. She was in Channel service until 1792 when she transferred to the Meditterranean where she remained until 1797 (with the exception of 3 months being repaired at Portsmouth in 1795) including taking part in the Battle of Cape St. Vincent.
In October 1797, she returned to Portsmouth where she was surveyed and found defective. She was therefore paid off and refitted as a hospital ship (and the ship's name was struck from the Navy List). That could have been the end of the story for this HMS Victory. However, the loss of a newer First Rate, Queen Charlotte, to a fire meant that the Navy required a replacement. Rather than building a new vessel from scratch, they chose to rebuild the Victory. This was a major reconstruction that took three years (and cost more than her original construction). When the reconstruction was complete, she was recommissioned and served as Nelson's flagship in the Mediterranean from 1803 to 1805. She was heavily damaged at Trafalgar and had temporary repairs at Gibraltar before returning to Chatham to be paid off in 1806. She then remained in ordinary until 1808 when she refitted as a 2nd Rate (which reduced the number and type of guns she carried). She was put back into service in December 1808 before being finally retired from active (sea) service in November 1812 (including a period as a troop ship). She then remained in ordinary until 1823, including another major reconstruction between 1814 and 1816 (this again cost more than her original construction and incorporated the construction of a new round bow).
From 1823 until 1922, she had various harbour roles which included being a guard ship, a Port Admiral's flagship and a tender to HMS Duke of Wellington as well as periods in ordinary. In 1922 she was dry-docked where she's remained ever since. However, being in dry dock has not meant an end to the reconstruction and repairs. The desire to re-create the 1805 version of ship meant that the round bow (introduced in 1816) had to be replaced with one in the original beakhead style and many of the later fittings had to be replaced with period replicas. From 1955, when a large scale repair was started, the ship has been in an almost continuous process of repairs.
Any water leads to rot in timber as it finds its way into the thousands of joints in the ship's structure, and those timbers that are completely or partially enclosed suffer most. The salt in sea-water is only mildly inhibiting, but the used of fresh water positively encourages rot and the regular washing-down of the decks carried on for years is thought to have been one of the reasons why so mauch of the repairs of the 1920s had to be reworked later. If the principle cause of the damage was caused by damp-induced rot, it was run close by decay caused by the death-watch beetle which had no doubt been present in the ship long before her docking in 1922.
HMS Victory, Her Construction, Career and Restoration, A.McGowan (Chatham, 1999)
And from the same source, an example of the scale of this work
The extent of the decay in the hold may be realised in that from bow to stern there are one hundred and forty-five timbers or frames on each side below the waterline. Of these, one hundred and one to port and one hundred and four to starboard had to be renewed or repaired...
So looking at the Victory's history it can be seen that she was only in active service for 18 years of her long life. An insignificant amount compared to the time she spent in harbor service, in the reserve and in dry-dock. Given the amount of repairs and reconstruction work throughout its life, its hard to determine if the vessel now sitting in No2 Dock in Portsmouth is truely the same ship that was launched in 1765.
As for the lifespan of wooden warships in general:
Without a detailed analysis of ship longevity, taking into account the frequency of repair and reconstruction work, the extent of active sea time, war service and other variables, it is impossible to determine the average life of a wooden warship. However, it is clear that larger ships, built with more attention to timber quality and seasoning, recieving higher levels of maintenance, serving in less demanding waters, did last longer. After the industrial revolution [naval architect] Seppings's attention to detail transformed the art of wooden shipbuilding, with remarkable results. Ships built using his methods lasted far longer than their precursors, without major rebuilds.
(Series Preface) British Warships in the Age of Sail 1603-1714, Andrew Lambert (Seaforth, 2009)
So ships that had could be genuinely be claimed to have continous active service running into decades are more likely to be larger vessels built in the nineteenth century.