How do I detect when I look away?

You can’t detect players looking at blocks with command blocks(by objects I assume you mean blocks). But you could use a player detector e.g half block gap with two blazes encased on the other side with a tripwire above them when they see a player they will fly up into the tripwire giving off a redstone signal.