A top executive for Walmart is leaving the retail giant at the end of the month to join the leadership ranks of KPMG LLP, one of the Big Four accounting firms, as general counsel.