In most cases logging off and on again solves the problem (until the layout changes unexpectedly again). When opening another application in the same session the keyboard layout changes unexpectedly. This is the opposite situation compared to scenario A.
Instead, the server-side keyboard layout on the worker (VDA) is used.
Each issue is linked to a section in this article that describes the causes and solutions:
Let's start with a list of the most common keyboard layout issues. The issues and solutions in this article apply to XenDesktop / Citrix Virtual Apps and Desktops (CVAD) version 7.12 and higher and Citrix Receiver 4.6 and higher.
Solving keyboard layout issues in an ICA or RDP session can be quite tricky. In this article I deal with some of the common causes and their solutions.