I recently upgraded the keyboard in my Dell E4300 from a standard USA model to a backlit UK model. All went great however I noticed that the keyboard layout kept switching back to the USA layout. It seemed to happen after every reboot, and also randomly in the middle of the session.
There’s even a bug in launchpad about it which I commented on: https://bugs.launchpad.net/ubuntu/+bug/762111
There were two factors causing the layout to switch and the USA layout to be reinstated.
Firstly when logging in the session was set to the USA layout. To fix this logout, select your user name and then look for the keyboard symbol down the bottom of the screen.
The second feature causing seemingly random switches during sessions was the “Separate layout for each window” option in Keyboard Preferences (Keyboard Preferences is in system settings and the option is on the layout tab).
If you deactivate this, remove the USA layout, apply system wide and make sure the GDM session is set to the correct layout on login you shouldn’t have any more problems with randomly switching keyboard layouts!