I actually had to just deal with this. We had to put our 15 year old dog to sleep on Friday.
My situation is a little different as my daughter is 6. We had to put our cat to sleep about a year and a half ago and so my daughter has had to deal with losing her pets a couple of times. I also have another elderly dog, he is 16, and we are hoping that he stays with us for at least another couple of months.
Anyway, this is not an easy subject but this is what I have figured out from my own personal experience.
With my cat, he was put to sleep while my daughter was at preschool, I am not sure that this was the best way to do it since she did not get a chance to say good-bye but it is just how it happened. I explained to my daughter that he had been really sick and that he was really old and that he passed away at the doctor's office. I explained to her that he now lives in heaven and that even though we can not see or hear him that he can see and hear us and that she could talk to him anytime she wanted. She cried some and all in all seemed to have handled it pretty well. Every once in a while I will see her at the back door on her knees and she tells me that she is talking to fats (the cat).
The dog that we just lost this last Friday was a little different. He was also sick but I was really hoping for a more positive outcome and had taken my daughter to the vet's office with me (it was close to the end of the day and I was not positive how long I would be and so I had picked her up early from camp). My husband met us at the vet's office. My daughter was in the room when the doctor told us that there was really nothing that we could do and that it really was time to put him to sleep. My husband took my daughter outside and explained to her that the doctor was going to give Rocko a shot and help him go to sleep and that he would then go to live in heaven and that he would be a puppy again and that he would get to play with fats. I took Rocko outside to where my husband and my daughter were and let both of them tell Rocko good-bye. I then took Rocko back in and had my husband wait with my daughter outside.
That is my story and here is my advice. I would explain to your 2 1/2 year old that the dog is old and sick. Depending on your religious beliefs that the dog is going to heaven to live with god, or your own version, and that even though you can't see him that he can see you guys and your family and that he is young and healthy again. As far as letting your son actually be in the room when the dog is being put to sleep I would strongly advise against this. The reason that I say that is because sometimes the animals body will actually fight the drugs and it is not pretty. I also just feel that it is way to traumatic of a situation for a young child to watch their pet die no matter how "peaceful" it is. Let your son say good-bye but do not make him be a part of the actual situation. I would suggest maybe seeing if your children can stay with friends of family on the day that you have to make that very tough decision just strictly for the fact that they do not see you upset. I know that in my case I was extremely upset and that only upset my daughter more because she was worried about me.
Sorry this has been so long winded. I wish you the best and I am sure that you will make the best decision for you and your family. I am also very sorry for the impending loss of your beloved family pet. My thoughts are with your family.