Save the old value before you change it. That is the whole trick.
Duplicate the existing PATH string, set your new value, do your work, then write the saved copy back and free the memory:
char *old_path = strdup(getenv("PATH"));
putenv("PATH=/new/path");
...
sprintf(tmp, "PATH=%s", old_path);
putenv(tmp);
free(old_path);
Using strdup matters here because getenv returns a pointer into the environment that you should not modify or free yourself.