As currently (v4.3) VirtualBox doesn’t provide the possibility for compacting VMDK files, you have to go for the workaround of converting it into a VDI file, compacting that one, and finally converting it back into a VMDK.
Here’s the gist of my example script for doing this.