Is just after your PhD a good time to switch your research area? I am finishing my PhD soon. The area in which I pursued my PhD is very challenging as I was only able to publish couple of papers even after spending many years. I want to switch into other research are due these reasons


to attract more students 
to be comfortable to do research (along with teaching, I should be able to do research)


Even though I like the research I am doing right now, I seem to be isolated in my university. If ten students join my university for a PhD, hardly one student takes this area. My research area is not like machine learning or deep learning etc, so researchers of my domain are also not that much interested in my work. 

The thing is I can work different research area but: Is this the right time? I am heading to a post-doc and learning a new area will probably take several months. Although my switch is not 180 degree, I am still worried.
This decision requires a fair amount of courage and planning. In short, yes, it is very much possible to switch your research area. Whether or not such a switch is successful depends on how well you plan it, and on the supportive nature of your future employers. You should be upfront with your postdoc advisor about your intention to switch. Because of the learning curve associated with the new area, expect a reasonable amount time (6 months or 1 year) before you can hope to produce research output in the new area. They should know this in case they are hiring you with the intention of fulfilling some funding obligations/deliverables in short time frames. My suggestion is to see if you could try to find a link betwee your current and intended area. If so, you could use this link as a bridge to move towards your new area, instead of all at once (which can be very overwhelming).