Searching for your quoted phrase online brings up a number of results all of which place the words inside inverted commas, suggesting they are all quoting something, as you surmised.
Among the results is this New Zealand newspaper of 1898, which makes reference to the words being from an 'old song' rather than from a novel.
There was a favourite old song that spoke of a parting and said, "It
might be for years and it might be for ever,"
Armed with this additional information one can search for the quote with the addition of 'song' and 'lyrics'. This readily brings up references to the song 'Kathleen Mavourneen', which does indeed 'speak of a parting' and was extremely popular in its day, and judging by the number of modern recordings available, remains so.
a song written in 1837, composed by Frederick Crouch with lyrics by a
The song evidently acquired a degree of cultural significance through becoming the signature concert tune of Irish soprano Catherine Hayes, and its theme of separation has spoken to many separated by war and migration.
With the information that the words are in fact lyrics, other sources abound including http://www.bellsirishlyrics.com which gives the lyrics, including these lines:
Oh have you forgotten how soon we must sever?
Oh have you forgotten this day we must part?
It may be for years and it may be forever
Oh why are you silent thou voice of my heart?
It may be for years and it may be forever;
Then why are you silent Kathleen Mavourneen?
Here is a recording from 1906 by opera singer Adelina Patti.
The phrase, as you have observed, occurs in many novels. Included in their number is Dickens' The Pickwick Papers (1836):
In bidding adieu to the modern Babylon, where we have undergone many vicissitudes, I trust not ignobly, Mrs. Micawber and myself cannot disguise from our minds that we part, it may be for years and it may be for ever, with an individual linked by strong associations to the altar of our domestic life.
Which is noted in Clarkson N. Potter's The Annotated Dickens as
a line from Julia Crawford's lyric 'Kathleen Mavourneen', set to music by F. H. Crouch and published in 1835 but performed earlier.
The reference to the song being performed earlier may be quite pertinent as, while The Pickwick Papers was published a year later than the year Potter gives for 'Kathleen Mavourneen', the date cited in Wikipedia, referencing 'The Annual American Catalogue' as source would have the song post-dating the novel. On consideration, this may simply reflect British and American publication dates, however, this would also seem to place Dickens' incorporation of the line as contemporaneous with its initial popularity.
Whilst not contemporaneous with the song or its early use, Musical Allusions in the Works of James Joyce: Early Poetry through Ulysses by Zack R. Bowen cites Kathleen Mavourneen as the source of the 'sarcastic misquotation'
May be for months and may be for never
which James Joyce uses in Ulysses.
In St. Martin’s Eve: A Novel (1866), Ellen Wood clearly identifies the song by name when it is performed by one of the characters:
Rose who hated dullness as she hated poison, started up and opened the piano, hoping perhaps to dispel is, and began to look amidst the pile of music. She chose an old song; and out-of-date by gone song that she had not sung for months, perhaps years. How came she to hunt it up? It was a strange coincidence; little less than a fatality. The song was "Kathleen Mavourneen." Had any one asked Rose to sing it, she would gave cast back a sarcasm on the "perverted taste," on "English ideas," "vandalism," and commenced instead some new Italian of German thing, and screamed through it in defiance. On this night she began the song of her own accord; and i say it was a fatality.
"to think that from Erin and thee I must part -
It may be for years, and it may be for ever -
Thus far had Rose sung, when deep sobs startled her. They came from Adeline. She had been leaning back in her grandmamma's fauteuil, pale and quiet, but full of inward agitation. The song seemed singularly applicable to her, and she had listened to its words ad they went on with an oppressed heart. Singularly applicable! She was leaving her country, her home, and her dear parents, it might be for years and it might be forever, in these moments of sadness, a straw will unhinge the outward composure.
What is interesting here is that the lyrics are quoted accurately as 'may be' while the character Adeline paraphrases to 'might', thus creating the line which the question originally asks about. So while this quotation is supportive evidence of 'Kathleen Mavourneen' being the original source, it may be possible that M. Harrow was correct and St Martin's Eve is the novel from which their quoted line originates.