How do sodium-potassium pumps differentiate between sodium and potassium?
$\ce{Na^+-K^+}$ ATPase (more commonly called the$\ce{Na^+-K^+}$ pump) is a transmembrane protein that consists of two types of subunits: The 1000-residue  $\alpha$ subunit contains the enzyme’s ATP and ion binding sites, and the 300-residue $\beta$ subunit facilitates the correct insertion of the  subunit into the plasma membrane.

The  subunit of this $160 \ Å$ long protein consists of a transmembrane domain (M) composed of 10 helices of varied lengths and, and three cytoplasmic domains, namely: the nucleotide- binding domain (N), which binds ATP; the actuator domain (A), so named because it participates in the transmission of major conformational changes; and the phosphorylation domain (P), which contains the protein’s phosphorylatable Asp residue.



The $\ce{Na^+-K^+}$–ATPase is an antiport that generates a charge separation across the membrane, because for every three positive charges exit the cell for every two that enter.

The key to how it functions lies in the precise phosphorylation of a specific Asp residue of the transport protein. ATP phosphorylates the transporter only in the presence of $\ce{Na^+}$, whereas the resulting aspartyl phosphate residue is subject to hydrolysis only in the presence of $\ce{K^+}$. 

Thus, the "pump" has two conformational states (called E1 and E2) with different structures, different catalytic activities, and different ligand specificities. 



Outline of the entire process


E1.ATP, which acquired its ATP inside the cell, binds three sodium ions to yield the ternary complex $\ce{E1.ATP.3Na^+}$.
The ternary complex reacts to form the “high-energy” aspartyl phosphate intermediate $\ce{E1-P.3Na^+}$.
This “high-energy” intermediate relaxes to one lower in energy, i.e $\ce{E2-P.3Na^+}$, and releases its bound sodium ions outside the cell.
$\ce{E2~P}$ binds two potassium ions from outside the cell to form an $\ce{E2-P.2K^+}$ complex. (structure pictured earlier)
The phosphate group is hydrolyzed, yielding $\ce{E2.2K^+}$.
$\ce{E2.2K^+}$ changes conformation to E1, binds ATP, and releases its two potassium ions inside the cell, thereby completing the transport cycle.


This enzyme appears to have only one set of cation binding sites, but they changes both their orientation and their specificity during the course of the transport cycle. The difference in specificity the two conformations have arises principally because the two ions differ in size.

The illustration given below, shows the ion binding site in this ATPase and one can easily note the difference in positioning of residues between the two conformations.



Particularly, I would like to call your attention to figure(s) a, b and c. The purple spheres represent sodium ions, and the green ones correspond to potassium ions. Fig a and b represent the same view of the ion binding site, and one can clearly see the slight positional differences of the residues which account for the difference in specificity.

Image Source(s): 
Voet and Voet, Biochemistry
and http://www.nature.com/nature/journal/v502/n7470/full/nature12578.html