One has to understand the relation between the Microprocessor / Processor , operating system and the applications , I thought putting it in the form of a diagram
If you look at the diagram , every layer consists of 32bit or 64bit modes, which means You can code / write your applications either in 32bit or 64bit and compile and run them on 32 bit / 64 bit . You cannot execute 64bit application on 32bit operating system but vice versa is possible which is running 32bit applications on 64bit operating system.
Later you operating system also needs to communicate with microprocessor / processor which can be again 32bit or 64 bit. Please understand that processor modes should be enabled by the Operating system on code segment , which means 64bit operating system can execute 64bit applications on 64bit processor mode