It makes sense that there is a cave along the shores of the York River at Yorktown, and that everyone knows that Lord Cornwallis was there and that he had to surrender, therefore he probably hid in the cave during the siege. However nicely that fits our picture of the famous British General, it is unlikely that he ever hid there to take cover from the American bombardment.
First, the cave is small. Generals in a battle would have lots of people coming and going constantly. The cave is out of sight of the main battle grounds. To make decisions, Cornwallis would need to know how things were progressing. While providing protection from incoming shells, it just is a bit too far.
Cornwallis was also a seasoned soldier. He understood the risks of war as did all the soldiers. Having your commander hiding in a cave while the rest of the army was being bombarded relentlessly was no way to inspire your forces to perform with utmost bravery that was required to win.
While we can't be sure exactly where Cornwallis was headquartered during the siege, it is believed he was in the Nelson mansion. The brick walls of this house are almost 2 feet thick and provided adequate protection from enemy fire. Some have even suggested that the cave may have been used as a gun placement help defend the British encampment from an attack by the navy. That too is highly unlikely. Cornwallis had a great number of ships in the harbor with plenty a cannons that could be used in any number of ways that would be far superior to a cannon tucked back inside a cave.
Should you like to visit the cave, it is along the beach front area just east of town next to the Archer House. A small parking lot is available next to the cave located at 624 Water Street.