To know which page of logical memory is related to which frame in main memory, the operating system uses a data structure called page table that it stores in memory. The page table behaves like a dictionary: the keys are page numbers, and the output values are frame numbers.
Finding the physical address from the logical address goes as follows:
The structure of the logical address. Taken from Bell, John T. "Main Memory." University of Illinois, Chicago.