The problem is caused by your inner ear being conditioned to the movement of the ship or boat and sending invalid signals to the brain. It takes some time for the inner ear to re-adjust.
There is a condition known as "mal de debarquement" where this persists for years but it is VERY rare and is most common in middle aged women.
You can use anti-motion sickness medication to help if the condition causes problems otherwise your body will reset itself in a few hours to a few days.
Take care,
Mike