I have a slightly different take on how to manage this situation: I would try to have a very good joke, at your own expense, about what you did. Now, you should still make sure that you do not touch your co-workers in a way that can be interpreted incorrectly.
Back to the joke, it gives you the opportunity to:
- Recognize your mistake and air it out without making a big deal out of it.
- Let you gauge if your co-worker actually took your action negatively.
Now, if you're not a good comedian and you don't have a good sense of humor, the joke might be difficult to pull off. If you fail to pull it off, it might look just as creepy. If you're not confident you can pull it off, then just follow the advice in the answers above.
What could be a good joke? Something like this:
"I think I have left my hand hanging on your shoulder too long the other day. If I ever do that again, feel free to stick a fork in it." Allow no more than a comment or two on this and move on to a different topic. Don't let the comments lead to a direction that's pointing towards the fact that you like your co-worker.
General Advice
Work isn't just a place you spend 8 hours of your day and go home like a robot. You do end up socializing with your co-workers and some do end up developing intimate relationships. That's not a bad thing. The best way to avoid being creepy in that kind of situation is to be very good at gauging social cues. In order to become good at gauging social cues, you need to practice a lot. Try not to make your office your practice ground, since mistakes there can harm your relationships with your co-workers.