Gerlafingen is a municipality in the district of Wasseramt in the canton of Solothurn in Switzerland.