Answer:
It is OK for you to get a dog if you are getting the dog so YOU can care for THE DOG, and while you are caring for THE DOG, it will comfort you naturally, as taking care of something else gives one a sense of accomplishment and may make you stronger.
However, it may not be OK if you get a dog for the sole purpose of THE DOG being there to comfort YOU when you have anxiety. The dog will instinctually see you as weak and will "claim" you as his own. When dogs are allowed to claim humans it is dominancy, and negative issues almost always arise. Read The Human Dog to find out more.