I have the same problem with a MacBook Pro Retina and since Yosemite.
I was able to track down the corresponding crash, at each occurance of the "log off" there is a WindowServer crash log generated. After goolging I've found this post in the Apple forums:
Summary of the post (detailed instructions are in the post)
The bug could be due to a memory leak in the video memory. Users with external monitor are much more susceptible to have the bug. Because it crashes the WindowServer, all connected users are logged out, but sometimes some of their process still remain running.
- Unplug all external monitor;
- Fix filesystem permissions using the Safe Mode;
- Reset the Mac SMC, and allow for a full start and shutdown afterwards;
- Reset the NVRAM (also called PRAM previously).
I've done these steps, and I cannot be sure that it solve the problem. These random logout occured not every day, and sometimes multiple times in the same day. But since I applied them (this morning) they do not occur anylonger, but that's still a bit short to be sure.
Anyway worth a try!!