64-bit applications are compiled to take advantage of 64-bit registers in x86-64 processors, which also requires that the processor is running in the proper mode, and the OS API call word lengths match.
32-bit operating systems usually use protected mode, which only allows the use of 32-bit registers (e.g.
EBX). On x86-64 processors, 64-bit compatibility is added as long mode, which 64-bit OS'es are run under.
Additionally, the 64-bit version of Windows includes the WoW64 compatibility layer that dynamically translates 32-bit API calls to the 64-bit equivalents, and switches the CPU between 32-bit protected and 64-bit long modes when the process is scheduled to be run.
Another interesting point that comes into play with 64-bit processors is hardware virtualization. Given the proper hardware support, one can sometimes run a virtual machine (e.g. using VirtualBox or VMWare) that contains a 64-bit guest OS, while the host OS is only 32-bit (again, given the availability of x86-64 hardware virtualization). For details on doing this with VirtualBox, see this section of the manual.