I don't mean scraping the sides, I mean ramming the front end full force into another ship.
On purpose, or accidentally?
Actually several cases of intentional ramming in World War 2. Most famously, PT-109 and John F. Kennedy. Of course, the boat was idling lights-out in the middle of the night and was plowed by a japanese destroyer. Probably an accident.
Ramming was originally standard protocol in defense against U-boats if they were too near to the hull to shoot with the boat's main guns. Ramming of submarines happened on several occasions. Eventually, however, this practice discontinued officially due to the severe damage caused by this tactic.
If you mean as a means to sink an enemy ship, as opposed to accidental impacts, ramming had its uses through both world wars.
In WW1, the HMS Dreadnought rammed and sunk U-29, the only recorded sinking of a submarine by a battleship. The RMS Olympic, sister ship to the Titanic, rammed U-103, forcing the crew to scuttle their boat.
Throughout the second world war, ramming was an occasionally employed tactic for attacking surfaced submarines. The tactic had several successes, but was officially discouraged due to the damage caused to the rammer. The last, purposeful, use of ramming is possibly the battle between USS Borie and U-405, which resulted in the combatants locked together and engaging each other with small arms (part of the post battle report states that one submariner was killed by a knife thrown into his stomach and another knocked overboard by a shell casing thrown by a gun commander).
Aside from the ramming of submarines, the destroyer HMS Glowworm is credited with ramming the Admiral Hipper during the German invasion of Norway. The Glowworm lost steering controls after attempting a torpedo attack on Hipper and ended up impacting the cruiser. Glowworm was heavily damaged and suffered a boiler explosion soon after, while the Admiral Hipper had a large hole ripped in her side and took on large amounts of water, requiring months of repairs. This, coupled with other losses from the Norway campaign limited the Kriegsmarine's willingness and ability to conduct surface operations for the rest of the war.
Quickly wiki skimming, it seems that there was an incident between US and Soviet naval vessels in 1988 that involved minor ramming, but not it seems not with the intent to sink.
My sources are:
Castles of Steel - Robert Massie
U- Boat Fact File - Peter Sharp
Edit:
If you're more interested in ramming as a planned, organized tactic for naval warfare, take a look at the Battle of Lissa. Fought between the navies of Italy and Austria-Hungary in 1866, the Austrian battle plan was based, in part, on closing with and ramming the Italian ships due to the disparity in firepower. The battle featured numerous ramming attempts, both successful and not, and lead for a while to the belief that ramming would be an effective tactic for some time. This resulted in the creation of ships like the [HMS Polyphemus](http://en.wikipedia.org/wiki/HMS_Polyphemus_(1881)) and [USS Intrepid](http://en.wikipedia.org/wiki/USS_Intrepid_(1874)), which would also serve as the inspiration for the HMS Thunder Child from H.G. Wells' War of the Worlds. These types were never proven in battle, in fact were rather a disappointment even in peacetime, and were superseded by the parallel development of the torpedo boat and then torpedo-boat destroyer, which we now know simply as destroyers.
A History of Sea Power - William Oliver Stevens