You need to make an appointment with your vet to have him examined for hip dysplasia and/or a luxating patella.
People are sometimes under the misapprehension that only large dogs like German Shepherds get hip dysplasia, while in reality it is possible for ANY breed to have it, no matter how big or small.
Small and toy breeds, however, are also prone to something called a luxating patella, the patella being the knee. Its human equivalent would be called a "trick knee". When the knee slips, the result is lameness. When it slips back into place, the lameness stops.
Hip dysplasia occurs when the femur head (or the caput ossis femoris, more commonly known as a ball joint in layman's terms) doesn't fit correctly into the acetabulum (the concave housing of bone known as the hip socket). With hip dysplasia, it's possible for it to only affect one side, or to affect one side more severely than the other, but dogs who have it will display varying degrees of lameness from time to time, they will have an odd gait (looking like they are "loose" in the rear) or they will bunny hop to keep weight off that leg. It could be that the femur head slips from the acetabulum and that's when he holds his leg out stiff. This would be a painful thing and perhaps his rubbing on the couch is his attempt to put it back into the sock because he may have done that one time and it worked, so he tries it now when it goes out. It's understandable that he wouldn't want to eat or drink or go for a walk when this happens becaus GAH!! It HURTS, MOM! Perhaps because of the construction of his hip joint it's possible for it to go in and out frequently, which is KIND of good because if it went out and stayed out he would absolutely have to have surgery to survive.
In either the luxating patella or hip dysplasia, the ultimate outcome will be surgery, however since he is so small, it isn't as critical that he be operated on as immediately as it would be if he were a large dog. You do have to remember, however, that he obviously IS in pain when it acts up, otherwise it wouldn't affect his appetite or his desire to go outside.
Please post back and tell us what the vet said. Good luck!
Ghilly
That was a great answer from Ghilly.
But also think about how he's feeling in himself, and get him some medication for the pain. At least do that for now, while the vet decides what is the matter, and what needs doing to fix it.
You are going to need to take him to the vet.