The job of the operating system is to keep track of which page points to which frame. This information is kept in a page table which, in its simplest form, is simply a table where each row has a page and an associated frame.
With a 32 bit address space and 4K pages there will be 1048576 pages in the page table. Assuming each entry in the page table takes up 32 bits (or 4 bytes) we have 1048576 * 4 == 4194304 bytes == 4MB of page table data to map the entire address space.
Page tables can have many different structures and are generally highly optimised, as the process of finding a page in the page table can be a lengthly process.