Do you have a problem with forgetting small details in general? If so, maybe you can work something out with your boss. If they trust you with the keys for the office, perhaps he will trust you with an extra key you can keep on your personal key chain. I doubt you locked your own car keys in the office, right?
I have/had a *terrible* problem with forgetting things. Now, I am better at having some semblance of a routine for checking to make sure I have everything I need. But, small changes will often throw me off. For example, normally I keep my cell phone in my purse. But, if it is charging, I tend to forget it more often.
When I first started to drive, I locked my keys in the car numerous times. I left books I needed at school, or left homework at home, or forgot music on the night of a performance! Sometimes, these moments of forgetfulness can be serious. Other times, they are just an inconvenience.
If the people you work with like you, trust you, and think you do a good job, they are more likely to overlook these moments as minor inconveniences that are worth putting up with in order to keep you around. And again, maybe your boss would be willing to work out a solution for "just in case" in the future.
My dad (70) is very absent-minded. I found out just a few days ago that he keeps *several* car keys hidden all around the outside of his truck because he has locked himself out so many times (this is not age related.)
It is very important that you learn to laugh at yourself. This is one of the most important things that I learned (which my now-husband really helped me with when I was younger.) We absent-minded people will do things that make ourselves look really dumb, but are usually amusing and endearing to those watching. They will laugh, not to make fun of us, but because our unintended silliness tickled them inside. Laugh along. Most of the time, it is funny and not a real problem.
It is effective to crack a joke at yourself first, if you can. Like, "Oh boy, I did it again!" Or, give yourself a nickname that has to do with the blunder. It could become an inside joke at the office, which will help you to bond with everyone.
Now, I will tell you a real problematic situation that happened to me in college. I had a job house sitting while a family I knew was away on vacation. Now, like I said, change can mess me up. So, this was a big change. I wasn't at home, my route to school was different, etc. They gave me two sets of keys. One was left outside as an extra set in case I locked myself out of the house. Well, you can imagine that I DID lock myself out of the house. I let myself in with the extra set of keys, and then locked myself out again with BOTH sets of keys inside the house. I did not realize this until I came home after 9PM from school. The house was a raised ranch, so I could not break into the upper windows. I discovered that I could break in to the basement, but I had to rip the window screen to get in. I did so, climbed through the window, and went into the garage. There, I learned that the door between the garage and the house was LOCKED. This was in the day before cell phones, and the telephone number to reach the people was inside anyways. I figured the best thing I could do was go across the street and convince the neighbors that I was legitimately supposed to be at the house across the street. The husband came home after 2nd shift, got out a ladder and helped me break into one of the second floor windows. I was so extremely embarrassed, and the family had to come home to a window with a ripped screen. I never house sat again.
I tell you this because I can laugh at this now. It didn't feel funny at the time, but I did learn to laugh at this predicament I caused. And that was a true major problem. You did not cause any such thing like this at work!