The two smallest rings are not very tolerant of even the slightest wear. If this is a very old cassette then it's likely that the teeth of the smallest cogs are worn or deformed enough to let the chain jump like that. It's a common failure mode.
They may have worked tolerably with the old chain because the wear of the old chain worked with the wear of the teeth. But now with the new chain it's less tolerant of the wear on the pressure face of the teeth and it wedges the chain up and off.
A new cassette will fix all this.