It is used when someone is really frustrated or stressed out. Especially if they are trying to deal with a lot of things at once or if they are confused about what's going on. Example: Ay me! Why can't I figure this out?
AY ME
Meaning of AY ME in English
Slang English vocab. Английский сленговый словарь. 2012