My understanding is that you have cold- and warm-sensing nerves. However, at very high temperatures, both can be activated. It’s not entirely known why, but it may enhance the painful feeling in order to make sure you avoid those temperatures, or may be differences in how the nerves transmit the feeling and cold is activated because it triggers a faster reaction. If your feet are cold, and then you add warm water, it mimics that high-temperature pain since both are being activated for separate reasons.
When your feet get **very** cold the nervous terminals in them (the neuroreceptors that make you *feel*) get numb. It is a way the body self protects from further pain from the cold. By putting your cold numb feet inside warm water, you are promoting the flow of blood to them, thus reactivating those neuroreceptors. This sudden reactivation is like a shock to them, that we feel as the discomfort you are talking about.
Latest Answers