We report optically detected nuclear magnetic resonance (ODNMR) measurements on small ensembles of nuclear spins in single GaAs quantum dots. Using ODNMR we make direct measurements of the inhomogeneous Knight field from a photo-excited electron which acts on the nuclei in the dot. The resulting shifts of the NMR peak can be optically controlled by varying the electron occupancy and its spin orientation, and lead to strongly asymmetric lineshapes at high optical excitation. The all-optical control of the NMR lineshape will enable position-selective control of small groups of nuclear spins in a dot. Our calculations also show that the asymmetric NMR peak lineshapes can provide information on the volume of the electron wave-function, and may be used for measurements of non-uniform distributions of atoms in nano-structures.