Like everyone else said, a betta and goldfish should not be housed together, because their requirements are just too different. Even if the two fish seemed compatible behaviorally speaking, the differences regarding betta and goldfish needs as far as temperature, diet, filtration, tank size, waste output, and more means putting bettas and goldfish together, especially a comet goldfish which can grow to over 1 foot is not recommended. However, while goldfish are a no go, there is a variety of compatible fish bettas can be housed with, but you will need a larger tank, as three gallons is fine for a betta, but not for betta+buddies. This site has a nice compatibility chart.
Also, a two gallon is not nearly big enough for a goldfish, especially a comet goldfish. While it might be fine for a very, very brief time IF your fish is tiny, you are keeping the water spotlessly clean with a good filter ,making sure there is no food waste etc, and are going to move it to a much much bigger filtered aquarium or pond preferably with other goldfish ASAP. The two gallon aquarium is not a suitable permanent home for any kind of goldfish, let alone a comet goldfish which A.) naturally can grow to over 1 whole foot in length B.) is one of the most active goldfish types, and therefore would do better with more room to move around, and C.) comets, like the common goldfish which they were bred from are social fish who do best with their own kind for company and can display symptoms of severe boredom without other fish, or at least items to interact with.
Since the comet cannot stay in the 2 gallon permanently, I suggest you either get a much bigger aquarium (or build a pond) for your goldfish or find somebody with a pond or huge aquarium who will be wiling to take it. You could also see if the pet store will be willing to take it back. If you like the pond idea and are in the northern hemisphere where it is getting to autumn, and if you are in a place where ponds freeze over, you should try to find someone with a pond quickly before they have to close up the pond and stop feeding their pond fish. Good luck!