I think this is what you are looking for:
heroku run rails runner -e production Rails.cache.clear
If you do not configure the environment, development will be used.
If this is a common task, such as flushing the cache, complete the rake task.
source share