Somewhere along the line, I guess the writers decided (correctly, in my opinion) that Sherlock Hemlock was funnier if he was incompetent. Here, however, he's either being disingenuous or he's been committing sandwich theft in some sort of fugue state. Either way, it's rather nervy of him to ask for the other half of the sandwich.
And why doesn't Ernie get mad when he finds out who ate his sandwich? Bless his little heart, he didn't want revenge or retribution or anything, he just wanted to know what happened, and he's perfectly satisfied with the knowledge.